1.数据渲染  {{msg}}

vue数据渲染、条件判断及列表循环

<template>
  <div >
    {{msg}}
  </div>
</template>

<script>
export default {
  name: 'app',
  data () {
    return {
      msg: 'Hello World'
    }
  }
}
</script>

<style>

</style>

 2.条件判断  v-if="XXX"

vue数据渲染、条件判断及列表循环

<template>
  <div id="app">
    {{msg}}
    <hr>
    <block v-if="state">
      你看到我了
    </block>

  </div>
</template>

<script>
export default {
  name: 'app',
  data () {
    return {
      msg: 'Hello World',
      state:true
    }
  }
}
</script>

<style>

</style>

 3:列表循环 v-for="(item,index) in list" :key="index"

vue数据渲染、条件判断及列表循环

<template>
  <div id="app">
    {{msg}}
    <hr>
    <block v-if="state">
      你看到我了
    </block>
    <hr/>
    <ol>
      <li v-for="(item,index) in list" :key="index">
        {{item.text}}
      </li>
    </ol>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      msg: "Hello World",
      state: true,
      list: [
        { text: "学习 JavaScript" },
        { text: "学习 Vue" },
        { text: "整个牛项目" }
      ]
    };
  }
};
</script>

<style>
</style>

 最终页面效果:

vue数据渲染、条件判断及列表循环

 

相关文章:

  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2021-11-19
  • 2021-08-08
  • 2021-07-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-22
  • 2021-09-02
  • 2021-08-06
  • 2022-12-23
  • 2021-06-24
  • 2021-06-07
相关资源
相似解决方案