1 this指向
vue中this指向的vm實例,如果map或者filter循環中,this的指向就是個迷了
解決辦法
- let _self = this
- ES6箭頭函數
2 scoped
表示了css的作用域,如果含有scoped表示css只作用域本模塊中,否則作用域全局
3 實例片斷
經常寫的時候會提示實例片斷錯誤,比如
實例片斷錯誤.png
為什么會出現這種問題
vue建議我們為片段添加一個根節點,這樣方便傳遞props和過渡效果,也可以讓dom更好的溯源如何解決呢?
很簡單,只需要用div包一層就好了
// 片段
<template>
<h1>hello</h1>
<h2>world</h2>
</template>
// 片段
<template>
<div>
<h1>hello</h1>
<h2>world</h2>
</div>
</template>