使用is标签解决模板出现bug的问题
有时候一些特定标签的子标签,用自定义的组件无法识别,必须通过is标签来解决这样的问题
举例如tbody标签下面必须用tr标签,指定自定义的组件row为tr就可以解决这样的问题:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue中的条件渲染</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="app">
<table>
<tbody>
<tr is="row"></tr>
<tr is="row"></tr>
<tr is="row"></tr>
</tbody>
</table>
</div>
<script>
Vue.component('row',{
template:'<tr><td>this is a row </td></tr>'
})
var vm = new Vue({
el: '#app',
})
</script>
</body>
</html>
vue中通过ref获取dom节点
- 当ref使用在div这样的标签上的时候,通过this.$refs.name获取到的内容实际上是标签对应的dom元素
- 当ref使用在组件上面的时候,获取到的是子组件的一个引用