vue初级尝试

为了跟上前端后台化的潮流,本少不得不开始关注vue,下列上机代码是针对App.vue进行的更改

  • 数据渲染----一般键值对,数组,对象和对象数组
<template>
  <div id="app">
    <img>
    <h1>
      {{msg}}
    </h1>
    <br>
    <br>
    <ul>{{mycoach.name}}</ul>
    <ul>芳龄:{{mycoach.age}}</ul>
    <ul>擅长武技:</ul>
    <ul v-for="item in mycoach.expertin">
      <li>{{item}}</li>
    </ul>
    <br>
    <br>
    <br>
    <ul span="margin-left:200px">歌词:别来纠缠我</ul>
    <ul v-for="item in chrouslist">
      <li>{{item}}</li>
    </ul>
  </div>
</template>

<script>
export default {
    data()
    {
        return  {
            msg:'欢迎来到帅哥vue',
            mycoach:{
                name:'陈培昌',
                age:22,
                expertin:['散打','泰拳']
            },
            chrouslist:['我不想对你再说些什么','现在是气愤的我','你是被你的虚伪完全淹没','变成讨厌的颜色','......']
        }
    }

}
</script>

输出结果:

附录:页面css样式

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

猜你喜欢

转载自www.cnblogs.com/saintdingspage/p/11412150.html
今日推荐