请问老师为什么会报错?
来源:2-9 class与style绑定
马铃薯胖鸭
2019-08-15 15:01:11
<template> <div>模板绑定</div> <div>-----------------------</div> <div v-bind:class="{'active':isActive,'text-danger':hasError}">hello</div> </template> <script> export default{ data(){ return{ isActive:true, hasError:false } } } </script>
1回答
同学你好,template下只能有一个直接子元素,但是这里有两个,所以报错了,可以在外层嵌套一个元素,例:
希望能帮助到你,欢迎采纳。
祝学习愉快!
相似问题