一、文章由来
在开发过程中发现在钩子函数位置直接使用dicts就能直接绑定数据了,由此溯源发现了自己的盲区

二、局部使用
// myMixin.js文件
var myMixin = {
created: function () {
this.hello()
},
methods: {
hello: function () {
console.log('hello from mixin!')
}
}
}
使用
mixins: [mixin],
三、全局使用
Vue.mixin({
created: function () {
var dicts= this.$options.dicts // 通过this.$options可以过去到所有钩子函数和自定义的同级方法
if (dicts) {
console.log(dicts) //打印结果: ["insurance_type","insurance_mode","livestock_type"]
}
}
})
使用
// dicts是和钩子函数同级的
dicts: [
"insurance_type",
"insurance_mode",
"livestock_type"
],





![Grafana+Prometheus构建强大的监控系统-保姆级教程[监控linux、oracle]](https://img-blog.csdnimg.cn/img_convert/c6b9487a73135c000f55cbae588d32e3.png)













