diff --git a/20_脚手架/vue_code/03.src_mixin混入/App.vue b/20_脚手架/vue_code/03.src_mixin混入/App.vue new file mode 100644 index 0000000..ba65631 --- /dev/null +++ b/20_脚手架/vue_code/03.src_mixin混入/App.vue @@ -0,0 +1,20 @@ + + + \ No newline at end of file diff --git a/20_脚手架/vue_code/03.src_mixin混入/assets/logo.png b/20_脚手架/vue_code/03.src_mixin混入/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/20_脚手架/vue_code/03.src_mixin混入/assets/logo.png differ diff --git a/20_脚手架/vue_code/03.src_mixin混入/components/School.vue b/20_脚手架/vue_code/03.src_mixin混入/components/School.vue new file mode 100644 index 0000000..684a3ed --- /dev/null +++ b/20_脚手架/vue_code/03.src_mixin混入/components/School.vue @@ -0,0 +1,28 @@ + + + + diff --git a/20_脚手架/vue_code/03.src_mixin混入/components/Student.vue b/20_脚手架/vue_code/03.src_mixin混入/components/Student.vue new file mode 100644 index 0000000..621788a --- /dev/null +++ b/20_脚手架/vue_code/03.src_mixin混入/components/Student.vue @@ -0,0 +1,28 @@ + + + + diff --git a/20_脚手架/vue_code/03.src_mixin混入/main.js b/20_脚手架/vue_code/03.src_mixin混入/main.js new file mode 100644 index 0000000..2aab4d0 --- /dev/null +++ b/20_脚手架/vue_code/03.src_mixin混入/main.js @@ -0,0 +1,16 @@ +import Vue from "vue"; +import App from "./App"; + +import {mixin_method1, mixin_method2} from "@/mixin"; + + +Vue.config.productionTip = false +Vue.mixin(mixin_method1) +Vue.mixin(mixin_method2) + +new Vue({ + components: { + App + }, + render: h => h(App) +}).$mount('#app') diff --git a/20_脚手架/vue_code/03.src_mixin混入/mixin.js b/20_脚手架/vue_code/03.src_mixin混入/mixin.js new file mode 100644 index 0000000..c41bd4f --- /dev/null +++ b/20_脚手架/vue_code/03.src_mixin混入/mixin.js @@ -0,0 +1,17 @@ +export const mixin_method1 = { + methods: { + showName() { + alert(this.name) + } + }, + mounted() { + console.log("欢迎") + } +} +export const mixin_method2 = { + data() { + return { + msg: "欢迎" + } + } +} \ No newline at end of file diff --git a/20_脚手架/vue_code/src/App.vue b/20_脚手架/vue_code/src/App.vue index 82ac3db..ba65631 100644 --- a/20_脚手架/vue_code/src/App.vue +++ b/20_脚手架/vue_code/src/App.vue @@ -1,15 +1,19 @@ + diff --git a/20_脚手架/vue_code/src/components/Student.vue b/20_脚手架/vue_code/src/components/Student.vue index 9245f8a..621788a 100644 --- a/20_脚手架/vue_code/src/components/Student.vue +++ b/20_脚手架/vue_code/src/components/Student.vue @@ -1,53 +1,28 @@ diff --git a/20_脚手架/vue_code/src/main.js b/20_脚手架/vue_code/src/main.js index 97aa3a1..2aab4d0 100644 --- a/20_脚手架/vue_code/src/main.js +++ b/20_脚手架/vue_code/src/main.js @@ -1,6 +1,13 @@ import Vue from "vue"; import App from "./App"; +import {mixin_method1, mixin_method2} from "@/mixin"; + + +Vue.config.productionTip = false +Vue.mixin(mixin_method1) +Vue.mixin(mixin_method2) + new Vue({ components: { App diff --git a/20_脚手架/vue_code/src/mixin.js b/20_脚手架/vue_code/src/mixin.js new file mode 100644 index 0000000..c41bd4f --- /dev/null +++ b/20_脚手架/vue_code/src/mixin.js @@ -0,0 +1,17 @@ +export const mixin_method1 = { + methods: { + showName() { + alert(this.name) + } + }, + mounted() { + console.log("欢迎") + } +} +export const mixin_method2 = { + data() { + return { + msg: "欢迎" + } + } +} \ No newline at end of file