完成scoped样式学习

new_branch1
roger 2 years ago
parent e354141f65
commit 5d6e590fc3
  1. 25
      20_脚手架/vue_code/5.src_scoped样式/App.vue
  2. BIN
      20_脚手架/vue_code/5.src_scoped样式/assets/logo.png
  3. 27
      20_脚手架/vue_code/5.src_scoped样式/components/School.vue
  4. 26
      20_脚手架/vue_code/5.src_scoped样式/components/Student.vue
  5. 16
      20_脚手架/vue_code/5.src_scoped样式/main.js
  6. 8
      20_脚手架/vue_code/src/App.vue
  7. 18
      20_脚手架/vue_code/src/components/School.vue
  8. 11
      20_脚手架/vue_code/src/components/Student.vue
  9. 4
      20_脚手架/vue_code/src/main.js
  10. 34
      20_脚手架/vue_code/src/plugins.js

@ -0,0 +1,25 @@
<template>
<div>
<School/>
<Student/>
</div>
</template>
<script>
import School from "./components/School.vue";
import Student from "./components/Student.vue";
export default {
name: "App",
components: {
School,
Student
}
}
</script>
<style>
.title {
color: red
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

@ -0,0 +1,27 @@
<template>
<div class="demo">
<h2 class="title">学校名称{{ name }}</h2>
<h2>学校地址{{ address }}</h2>
</div>
</template>
<script>
export default {
name: "School",
data() {
return {
name: "修仙学院",
address: "长白山",
msg: "欢迎学校" // vc
}
},
}
</script>
<style lang="css" scoped>
.demo {
background-color: orange;
}
</style>

@ -0,0 +1,26 @@
<template>
<div class="demo">
<h2 class="title">学生名称{{ name }}</h2>
<h2>学生年龄{{ age }}</h2>
</div>
</template>
<script>
export default {
name: "Student",
data() {
return {
name: "小强",
age: 18,
msg: "欢迎学生"
}
}
}
</script>
<style lang="css" scoped>
.demo {
background-color: skyblue;
}
</style>

@ -0,0 +1,16 @@
// 引入Vue
import Vue from "vue";
// 引入App
import App from "./App";
// 设置Vue
Vue.config.productionTip = false
// 实例化Vue
new Vue({
components: {
App
},
render: h => h(App)
}).$mount('#app')

@ -16,4 +16,10 @@ export default {
Student
}
}
</script>
</script>
<style>
.title {
color: red
}
</style>

@ -1,8 +1,7 @@
<template>
<div>
<h2>学校名称{{ name | mySlice}}</h2>
<div class="demo">
<h2 class="title">学校名称{{ name }}</h2>
<h2>学校地址{{ address }}</h2>
<button @click="test">点击触发hello方法</button>
</div>
</template>
@ -12,16 +11,17 @@ export default {
name: "School",
data() {
return {
name: "修仙学院修仙学院修仙学院",
name: "修仙学院",
address: "长白山",
msg: "欢迎学校" // vc
}
},
methods: {
test() {
this.hello()
}
}
}
</script>
<style lang="css" scoped>
.demo {
background-color: orange;
}
</style>

@ -1,8 +1,7 @@
<template>
<div>
<h2>学生名称{{ name }}</h2>
<div class="demo">
<h2 class="title">学生名称{{ name }}</h2>
<h2>学生年龄{{ age }}</h2>
<input type="text" v-fbind:value="name">
</div>
</template>
@ -19,3 +18,9 @@ export default {
}
</script>
<style lang="css" scoped>
.demo {
background-color: skyblue;
}
</style>

@ -2,14 +2,10 @@
import Vue from "vue";
// 引入App
import App from "./App";
// 引入插件
import plugins from "./plugins"
// 设置Vue
Vue.config.productionTip = false
// 使用插件
Vue.use(plugins)
// 实例化Vue
new Vue({

@ -1,34 +0,0 @@
export default {
install(Vue) {
// 全局过滤器
Vue.filter("mySlice", function (value) {
return value.slice(0, 4)
})
// 全局指令
Vue.directive("fbind", {
bind(element, binding) {
element.value = binding.value
},
inserted(element, binding) {
element.focus()
},
update(element, binding) {
element.value = binding.value
}
})
// 定义混入
Vue.mixin({
data() {
return {
x: 100,
y: 200
}
}
})
// 给Vue原型上添加一个方法
Vue.prototype.hello = ()=> {alert('Hello')}
}
}
Loading…
Cancel
Save