复习
名字还我
戴劳
展开
-
vue全局事件总线bus
main.js new Vue({ el:'#app', render: h => h(App), beforeCreate() { Vue.prototype.$bus = this //安装全局事件总线 }, }) 子组件 <button @click="sendStudentName">把学生名给School组件</button> methods: { sendStudentName(){ this.$bus.$emit('hello',th原创 2022-02-09 10:56:33 · 691 阅读 · 0 评论 -
mixin混入
mixin.js export const hunhe = { methods: { showName(){ alert(this.name) } }, mounted() { console.log('你好啊!') }, } export const hunhe2 = { data() { return { x:100, y:200 } }, } main.js import {hunhe,hunhe2} from './mixin' Vue.mixin原创 2022-02-09 10:20:04 · 443 阅读 · 0 评论