【问题标题】:A href and click events ? concurrently perform?一个href和click事件?并发执行?
【发布时间】:2018-07-01 18:16:54
【问题描述】:

Vue

目标:编码一个循环数组,一个链接锚点‘href’

<a class="mui-control-item"
    v-for="(item, index) in dai" v-on:click ="abc(item)" :href="'#item'+(index+1)+ 'mobile'"
    :key="index"
    :class="{'mui-active':!index}">
    <!-- <p  style="z-index: 99;"> -->
    {{item.value}}
    <!-- </p> -->
</a>

方法:点击获取的参数

abc(item, index) {
    // location.href = '#item' + (index + 1) + 'mobile'
    this.oIndex = item
    console.log(oIndex, 'aa')
}

我想让它是'click'和'href'同时执行或者一个接一个,我不需要点击两次

【问题讨论】:

  • 不幸的是,这不是“给我我想要的”那种服务。 Learn how to ask question here.
  • 你想达到什么目的?如果 href 指向另一个页面,那么您的脚本将不会被执行。
  • 我是初学者,英文不好,想通过点击获取参数并使用V-IF传递给子页面
  • 请重新表述您的问题。另外,正如@jeff 指出的那样,您要么运行该功能,要么离开。选择一个。

标签: javascript html vue.js


【解决方案1】:

试试这样:

<div class="mui-control-item" v-for="(item, index) in dai" @click="abc(item, index)" :key="index" :class="{'mui-active': !index}">

abc(item, index) {
    this.oIndex = index;
    console.log(index, 'aa');
    this.$router.push('item/' + (index + 1) + '/mobile');
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-27
    • 1970-01-01
    相关资源
    最近更新 更多