在vue组件中添加click事件无效,@click.native也无效
在vue组件中添加click事件无效,@click.native也无效
·
在网上查了很久,也试了各种解决办法,如下情况都无法解决问题:
@click="onSubmit"
@click.native="onSubmit"
:click="onSubmit".
最后用v-on:click="onSubmit"解决了问题,具体代码如下:
<el-form-item>
<el-button type="primary" v-on:click="onSubmit" round>更新数据</el-button>
</el-form-item>
<script>
var Main = {
data() {
return {
tabPosition: 'left',
form: {
//CIM_type: '',
//CIM_date: '' ,
type: '',
date: ''
}
}
},
methods: {
onSubmit() {
console.log(this.form.type)
console.log(this.form.date)
var D_api = "";
this.$http.post(D_api, { params: { val: this.form.date} }).then(
function (response) {
if (response.data.code == 0) {
Toast({
content: '数据更新成功!',
});
}
else if (response.data.Code == 500) {
Dialog.failed({
title: '数据更新失败',
content: response.data.msg,
confirmText: '确定',
onConfirm: () => console.log('[Dialog.failed] confirm
clicked'),
});
}
else {
}
}
).catch(function (response) {
// console.log("400", response);
});
},
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
</script>
更多推荐
已为社区贡献1条内容
所有评论(0)