如果十几个页面都会用到这个判断可以封装一个js页面
第一步:首先我在src目录下新建了一个news.js文件
data() {
return {
isQuery:false,
}
}
methods:{
newsTips () {
if(!this.isQuery) {
message: '警告哦,这是一条警告消息';
type: 'warning';
return true;
}
}
}
第二步在需要用到的页面引入
import news form '@/news'
export default {
//mixins 混入 引入需要的对象即可
mixins:[news],
data() {
},
methods: {
//查询事件改为true
onClick() {
this.isQuery = true
}
//导出事件调用一下即可
export() {
if(this.newsTips()) return;
}
}
}
补充:如果表格有点击跳转到另一个tab页,跳转之后默认查询状态:this.isQuery = !this.isQuery