简体   繁体   中英

Can I assign a click event or <A> on a whole Ember component?

I have an Ember component with tagName:'li'

The template looks like so:

<div> title</div>
 <div> image </div>
 <div> text </div>

The outcome is <li> blocks of the above elements, like so:

<li id="ember2484" class="...">
  <div>...</div>
  <div>...</div>
  <div>...</div>
</li>

I need to make the <li> clickable somehow, because I have a link url that I want to assign to each <li> element.

Is that possible, to make <li> clickable?


import Component from '@ember/component';

export default class extends Component {
  clickCounter = 0;

  click() {
    this.set('clickCounter', this.clickCounter + 1); 
  }
}

// or in the old syntax

import Component from '@ember/component';

export default Component.extend({
  clickCounter: 0,

  click() {
    this.set('clickCounter', this.clickCounter + 1); 
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM