码迷,mamicode.com
首页 > 其他好文 > 详细

vue 起步_code

时间:2017-10-28 19:52:19      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:import   eth   lock   html   scope   his   cal   nan   nbsp   

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <div>{{data1}}</div>
    <ul>
      <li v-for="(item, index) in list">
        {{item.name}} - {{item.price}} - {{index}}
      </li>
    </ul>
<!--     <p v-text="hello"></p>
    <p v-html="hello"></p>
    {{ num + 1}}

    <ul>
      <li v-for="item in list" v-text="item.name + ‘-‘ + item.price">
      </li>
    </ul>
    <ul>
      <li v-for="(item, index) in objList">
        {{index + ":" + item}}
      </li>
    </ul> -->
    <!-- <componentA v-for="(item, key) in objList" >
    </componentA>  -->
    <button v-on:click="addItem">addItem</button>
    <a v-bind:href="linlk" :title="linlk">to baidu</a>
    <a class="ccc" v-bind:class = "classStr"> to calss</a>
    <a class="ccc" v-bind:class = "[classRed,{‘blue‘:blueSwitch}]"> 控制class</a>
    <button v-on:click="clickBlue">clickBlue</button>
    <p v-if="blueSwitch">isPartA</p>
    <p v-show="blueSwitch">isPartB</p>

  </div>
</template>
<script>
import Vue from vue
//引入组件
import componentA from ./a
export default {
  components:{
    componentA:componentA
  },
  name: HelloWorld,
  data() {
    return {
      msg:  helloWord ,
      hello: <span> word</span>,
      num: 1,
      data1:data1,
      list: [{
          name: apple,
          price: 64
        },
        {
          name: banana,
          price: 25
        }
      ],
      objList:{
        name:tong,
        possword:123456465,
        id:vasd,
        group:01
      },
      linlk:http://www.baidu.com,
      classStr:[classStr,classStr1],
      classRed:[classRed],
      blueSwitch:true,
    }
  },  
  methods:{//事件
    addItem (){
      this.list.push({
        name :pinaapple,
        price:2564
      });
      console.log(this.list);
      Vue.set(this.list,1,{
        name :changeAapple,
        price:111
      });

    },
    clickBlue (){
      if(this.blueSwitch == false){
          this.blueSwitch = true;
          return false;
      }
      if(this.blueSwitch == true){
          this.blueSwitch = false;
          return false;
      }
    }
  }
}

</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  /* display: inline-block; */
  margin: 0 10px;
}
a {
  color: #42b983;
}
.blue {
  color: blue;
}
</style>

 

vue 起步_code

标签:import   eth   lock   html   scope   his   cal   nan   nbsp   

原文地址:http://www.cnblogs.com/tongbiao/p/7747638.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!