我正在Chrome扩展上进行帐户删除,我有以下按钮:

<button @click="remove" id="button_remove" class="btn btn-default" style="float: right;">Remove Account</button>

JS

methods:{
    remove(event){
       app.removeAccountData(url,apikey);
    }
},

我还有这个router-link:

<router-link :to="{ name: 'RemovedWId', params: { accountid: chosenAccount.apikey}}" text="delete_account"><span class="glyphicon glyphicon-trash" aria-hidden="true" style="margin-top: 2px; cursor: pointer;"></span> Remove Account</router-link>

有没有办法将router-linkJS功能结合使用?

推荐答案

由于<router-link><a>的组件包装器,我们需要使用.native修饰符来正确接收事件:

<router-link @click.native="remove" to="/remove">Remove</router-link>

demo

Vue.js相关问答推荐

Nuxt.js i18n不提供默认区域设置中的页面而不重定向

具有VUE身份验证的Azure AD

Nuxt3: 安装vue3-spinner (error: require is not defined in ES module scope)

NUXT 3 在客户端获取数据

props至少应该定义它们的类型

使用 Nuxt 动态获取文件夹中的图像路径

Vue子组件等待props

在 VueJS 中存储图像的正确位置是什么 - 公共文件夹或assets文件夹?

Laravel Vue - 如何让 vue 在公共文件夹中查找图像

在没有组件的vue js中拖放

如何从我的 Vuetify 数据表中正确更新 Vuex 状态

Transition-group children must be keyed...but they are keyed

如何判断 Vue 组件是否处于活动状态

事件 click点击的无效处理程序:未定义

如何在 Vue.js 中获取组件元素的 offsetHeight?

当 v-for 与对象的属性一起使用时,将 v-model 与复选框一起使用

在手动安装的 vue 组件中使用 vuex

执行调度程序刷新期间未处理的错误,这可能是一个 Vue 内部错误

vuejs 配置:使用全局变量?

表格行上的 Vuejs 转换