javascript - vue.js watch 监听以对象存取的数据,不能取到具体的值?
PHP中文网
PHP中文网 2017-04-11 12:25:26
[JavaScript讨论组]
handleRowHandle(row){ 
            var startPoint = [];
            startPoint.push(row.StartLONG);
            startPoint.push(row.StartLAT);

            var endPoint = [];
            endPoint.push(row.EndLONG);
            endPoint.push(row.EndLAT);
            
            this.mapoint.length = 0;
            this.mapoint.push(startPoint);
            this.mapoint.push(endPoint);
         },

事件获取坐标值。


绑定。传给子组件。

  export default{
            name:'amap',
            data:function(){
                return {
                    positions:[],
                }
            },
            props:['childmapoint'],
            mounted: function () { 
                console.log("jjjjjjj")
                console.log(this.childmapoint)
            //地图初始化  
            this.map = new AMap.Map(this.$el, {
                resizeEnable: true,
                zoom: 12,
            })           
        },
    
        watch:{
            childmapoint:function(){
                console.log(this.childmapoint)
                
                //清除所有的地图覆盖物
                this.map.clearMap();
                this.positions = this.childmapoint;
                for(let i=0;i

这种方式可以传值。

我把点击事件获取指的方式。变成了:

 handleRowHandle(row){
              console.log(row);
                 this.mapValueObj.EventTypeObj = row.EventType;
                 this.mapValueObj.PlateNumberObj = row.PlateNumber;
                 this.mapValueObj.StartTimeObj = row.StartTime;
                 this.mapValueObj.StartMessageObj = row.StartMessage;
                 this.mapValueObj.EndTimeObj = row.EndTime;
                 this.mapValueObj.EndMessageObj = row.EndMessage;
                
             var startPoint = [];
             startPoint.push(row.StartLONG);
             startPoint.push(row.StartLAT);

             var endPoint = [];
             endPoint.push(row.EndLONG);
             endPoint.push(row.EndLAT);
            
             var mapoint = [];
             mapoint.length = 0;
             mapoint.push(startPoint);
             mapoint.push(endPoint);
             this.mapValueObj.mapointObj = mapoint;
            console.log(this.mapValueObj)

          },

变成了传递对象。


子组件

       name:'amap',
            data:function(){
                return {
                    positions:[],
                }
            },
            props:['childmapoint'],
            mounted: function () { 
            //地图初始化  
            this.map = new AMap.Map(this.$el, {
                resizeEnable: true,
                zoom: 12,
            })           
        },
          watch:{
            childmapoint:function(){
                //清除所有的地图覆盖物
                this.map.clearMap();
                this.positions = this.childmapoint.mapointObj;
                for(let i=0;i

传值不成功?问题出在哪?

PHP中文网
PHP中文网

认证0级讲师

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号