vue.js中数组是用单中括号来表示的,其数组的创建方法是:首先创建一个代码示例文件;然后通过语句“
数组
”来定义一个数组即可。

本教程操作环境:windows7系统、vue2.0版,DELL G3电脑。
【相关文章推荐:vue.js】
Vue.js中字符串、对象、数组的表示方法
1、字符串是双大括号 {{ }}
2、对象是单大括号 { }
3、数组是单中括号 [ ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <div id= "app" >
<!--字符串-->
<p : class = "a" >{{str}}</p>
<!--对象-->
<p : class = "{aClass:isA,bClass:isB}" >对象</p>
<!--数组-->
<p : class = "['aClass','bClass']" >数组</p>
</div>
<script type= "text/javascript" src= "../js/vue.js" ></script>
<script type= "text/javascript" >
const vm= new Vue({
el: '#app',
data: {
a: 'aClass',
str: '字符串',
isA: true,
isB: false
},
})
</script>
|
登录后复制
以上是vue.js中数组怎么表示的详细内容。更多信息请关注PHP中文网其他相关文章!