Vue全局变量使用与修改
content.jsexport default {msg: "Hi",setMsg(msg) {this.msg = msg;}}main.js 注入import content from './common/content.js';Vue.prototype.$myContent = content;使用this.$myContent.msg修改this.$myContent.setMsg("
·
content.js
export default {
msg: "Hi",
setMsg(msg) {
this.msg = msg;
}
}
main.js 注入
import content from './common/content.js';
Vue.prototype.$myContent = content;
使用
this.$myContent.msg
修改
this.$myContent.setMsg("Hello Wrold!!");
更多推荐
已为社区贡献17条内容
所有评论(0)