美文网首页
vue 起步02

vue 起步02

作者: 喔爹 | 来源:发表于2018-09-14 17:52 被阅读0次
v-for =" "循环数组
v-model =" "双向数据绑定  用于表单元素
v-on:事件名=“ ”  绑定事件
v-bind属性名“ ” 绑定属性
v-show=“ ” 控制元素显示隐藏
v-text
v-html
v-once
v-pre
1 v-for

<ul>
            <li v-for="arrs in arrs">{{arrs}}</li>
 </ul>

<script>
        new Vue({ 
            el:'#itany',
            data:{
                arr:[1,2,3,4,5],
            }
        })
    </script>
2 v-model

<div id='app'>
            <input v-model="message">
            <p>{{message}}</p>
</div>
<script src="vue/dist/vue.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            var arr = new Vue({
              el: '#app',
              data: {
                message: 'Hello Vue.js!'
            }
        })
        </script>

3 v-on
 <div id='itany'>
       <button v-on:click='alt'>按钮</button>
   </div>
<script>
      var vm=new Vue({
            el:'#itany',
            data:{
                msg:'hello'
            },
            methods:{
                alt:function(){
                    console.log(vm.msg);
                }
            }
        }
    </script>
4 v-bind
               <div id="itany">
            <img v-bind:src="ct" v-on:click="cts">
        </div>
        <script src="vue/dist/vue.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            new Vue({
                el:'#itany',
                data:{
                    ct:'image/1.bmp'
                },
                methods:{
                    cts:function(){
                        this.ct='image/2.jpg'
                    }
                }
            })
        </script>
5 v-show
<div class='aa'>
     <h1>{{me}}</h1>
     <h3 v-show="seen">{{me}}</h3>        
     <button v-on:click="fun">回来</button>          
</div>
<script>
      new Vue({
            el:".aa",
            data:{
                  me:"才才",
                  me:“桶桶”,
                  seen:false      
            }
            methods:{
                  fun:function(){
                        this.seen=!this.seen          
                  }
            }
      })
</script>


v-text
v-html
v-once
v-pre

<div id="app">
            <input type="text" v-model="me">
            <p v-html="me">{{me}}</p>
             <h3 v-text='me'>{{me}}</h3>
       
       <a href="" v-once>{{me}}</a>
       
       <h1 v-pre>{{me}}</h1>
        </div>
        <script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            new Vue({
                el:"#app",
                data:{
                    me:'hello Word'
                }
            })
        </script>

相关文章

  • vue 起步02

  • vue-cli 起步配置步骤

    Vue-Cli 是 vue 专用起步工具,用 Vue-Cli 起步能够:① 项目直接安装了Vue、Vue-Rout...

  • Vue 2.0 起步(3) 数据流vuex和LocalStora

    参考: Vue 2.0 起步(2) 组件及vue-router实例 - 微信公众号RSS Vue 2.0 起步(1...

  • Vue 基础

    Vue 起步 Vue V-for循环 (一) Vue V-for 循环(二) Vue v-for表格

  • Vue起步

    1. hello world 项目 打开chrome devtools 感受双向绑定

  • VUE 起步

    单页面 SPA 网页应用的关键在于路由, 过去一个个按钮都会跳转到一个个独立的页面, 由服务器端渲染, 填充相应的...

  • vue起步

    vue官方文档:cn.vuejs.org/v2/guide 兼容性 Vue不支持IE8及以下版本,因为Vue使用了...

  • Vue起步

    1 Hello world 2 TodoList 3 TodoList 改进

  • vue起步

    今天是我学习vue框架的第一个月,我知道什么是spa,什么事单页应用。 什么是大前端!~

  • vue起步

    vue是什么? Vue.js(读音 /vjuː/,类似于 view) 是一套构建用户界面的渐进式框架。与其他重量级...

网友评论

      本文标题:vue 起步02

      本文链接:https://www.haomeiwen.com/subject/hinogftx.html