vue demo详解
JavaScript Code复制内容到剪贴板
- <!--生产-结算养费-->
- <template>
- <div class="container-fluid px-0" id="procution-support">
- <button @click="toArea()">测试</button>
- <h1 v-text="title"></h1>
- <span v-if="showBar">是否展示</span>
- <div>
- <ul>
- <li v-for="item in arr">
- <p><span v-text="item.name"></span>,<span v-text="item.age"></span></p>
- </li>
- </ul>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'procution-support',
- data () {
- return {
- title: '',
- showBar: true, // true展示,false不展示
- arr: []
- }
- },
- mounted: function(){ // 这个是页面创建的时候,就执行相关的方法
- this.getData()
- this.packageArray()
- },
- methods: { // 这里放方法,方法之间用逗号隔开
- getData () {
- // 假如这里是一块ajax请求,请求成功后,获取到title
- this.title = '页面标题'
- },
- toArea () {
- this.arr = [
- {name: '测试1', age: 17},
- {name: '测试2', age: 18},
- {name: '测试3', age: 19},
- {name: '测试4', age: 20}
- ]
- console.log('aaa')
- },
- packageArray () {
- // this.arr = [
- // {name: '测试1', age: 17},
- // {name: '测试2', age: 18},
- // {name: '测试3', age: 19},
- // {name: '测试4', age: 20}
- // ]
- }
- }
- }
- </script>