Blogger Information
Blog 20
fans 0
comment 0
visits 8159
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vue 基本语法
P粉191340380
Original
408 people have browsed it

数据绑定

  1. <template>
  2. <div>我是数据</div>
  3. <div>我是{{shuju}}</div>
  4. </template>
  5. <script>
  6. export default{
  7. data(){
  8. return{
  9. shuju : "数据"
  10. }
  11. }
  12. }
  13. </script>

事件绑定

// 语法糖: v-on = @

  1. <template>
  2. <div @click="fun()"> {{button}} </div>
  3. </template>
  4. <script>
  5. export default{
  6. data(){
  7. return{
  8. button : 点击事件,
  9. num : 10
  10. }
  11. }
  12. }
  13. methods : {
  14. fun(){
  15. console.log('方法1');
  16. }
  17. }
  18. </script>

if 判断

  1. // v-if判断, 值为真就显示, 值为假就不显示
  2. <template>
  3. <div v-if="show"> 点击事件 </div>
  4. </template>
  5. <script>
  6. export default{
  7. data(){
  8. return{
  9. show : false,
  10. num : 10
  11. }
  12. }
  13. }
  14. </script>

循环

// vue的循环是循环的值,放前面

  1. <li v-for="v in name">{{v}}</li>
  2. <script>
  3. export default{
  4. data(){
  5. return{
  6. name : [
  7. "老一",
  8. "老二",
  9. "老三",
  10. "老四",
  11. "老五",
  12. "老六"
  13. ]
  14. }
  15. }
  16. }
  17. </script>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post