Vue的基本使用

Vue

基础语法

js部分

  1. var vm = new Vue({
        el : '#目标id',
        data : {
            message: '',
            list: ['',''],
            map : {
                'key':'value'
            }
        },
        methods:{
            methodName : function(){
                methodContent;
                return
            }
        },
        //通讯
        data():function(){
        	return {
                info:null
            }
    	},
        mounted(){
            axios.get("url")
                 .then(response => (this.info = response))
            	 .catch(function(error){
                	console.log(error);
            });
        },
        watch:{
            prop:function(val){
             this.props = val;
            }
        }
    })
    vm.$watch('count',function(nval,oval){
       	alert(nval + oval); 
    });
    
  2. Vue.compenent('tagName',{
        template: 'tagContent',
     props:['','']
        //data要是返回对象则数据不唯一,返回函数则数据唯一
        data:function(){
        	return{
                props: 0;
            }
    	}
        methods:{
        	methodName:function(){
    			methodContent:
                this.$emit('')
        		return;
    		}
    	},
        
    })
    

    html部分

    1. <div id=''>
          {message}
          <ul v-for='i in list'>
              <li>{{i}}</li>
          </ul>
          <ul v-for='(key,value,index) in map'>
              <li>{{key}}{{value}}{{index}}</li>
          </ul>
          //v-on = @: v-bind = ;
          <button v-on:click='methodName' v-bind:attritute=''>
          </button>
      </div>
      
    2. <div id=''>
          <tagName v-bind:prop='message' v-on:methodName='methodName'></tagName>
      </div>
      
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值