Обнаружение щелчка в любом месте элементов DOM с помощью React

Начиная с 2013 года, если вы используете facebook.com/sharer.php (PHP), вы можете просто создать любую кнопку / ссылку, например:

<a class="btn" target="_blank" href="http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo urlencode(YOUR_TITLE);?>&amp;p[summary]=<?php echo urlencode(YOUR_PAGE_DESCRIPTION) ?>&amp;p[url]=<?php echo urlencode(YOUR_PAGE_URL); ?>&amp;p[images][0]=<?php echo urlencode(YOUR_LINK_THUMBNAIL); ?>">share on facebook</a>

Параметры запроса ссылки:

p[title] = Define a page title
p[summary] = An URL description, most likely describing the contents of the page
p[url] = The absolute URL for the page you're sharing 
p[images][0] = The URL of the thumbnail image to be used as post thumbnail on facebook

Это просто: вам не нужны никакие js или другие настройки. Это всего лишь HTML-ссылка. Создайте тег A любым способом, который вы хотите.

0
задан Telepresence 16 January 2019 в 05:10
поделиться

2 ответа

var last = new Date().getTime();

window.addEventListener('click', function(event) {

  var now = new Date().getTime();

  console.log(event.pageX, event.pageY);

  console.log(now-last);

  console.log((now-last) / 1000);

  if ( (now-last) < 2 * 60 * 1000 ) {
    console.log('clicked less than two minutes ago');
  }

  last = now;

});

0
ответ дан xloremxx 16 January 2019 в 05:10
поделиться
 class ClickTracker extends Component {
   trackClick(e){

   }

   componentWillMount() {
     document.addEventListener('click', this.trackClick); 
   }

   componentWillUnmount() {
     document.removeEventListener('click', this.trackClick);
   }

   render(){
     return (
         {this.props.children}
     );
   }
 }

0
ответ дан Mike Zinn 16 January 2019 в 05:10
поделиться
Другие вопросы по тегам:

Похожие вопросы: