当前位置: 首页 > wzjs >正文

办个网站需要投资多少网线制作心得体会

办个网站需要投资多少,网线制作心得体会,wordpress更新文章,用lamp搭wordpress提示:父组件中循环生成多个子组件时,有且只有最后一个子组件的watch对象生效问题及解决办法 文章目录 [TOC](文章目录) 前言一、问题二、解决方法——使用function函数代替箭头函数()>{}总结 前言 ‌‌‌‌‌问题:子组件用that解决watch无…

提示:父组件中循环生成多个子组件时,有且只有最后一个子组件的watch对象生效问题及解决办法

文章目录

    • @[TOC](文章目录)
  • 前言
  • 一、问题
  • 二、解决方法——使用function函数代替箭头函数()=>{}
  • 总结

前言

‌‌‌‌‌问题:子组件用that解决watch无法获取this,this为undefined问题,循环生成多个子组件,只有最后一个子组件的watch触发了多次;
原因:that是声明在打包的js文件中,每个子组件都会覆盖that为当前组件的this,最后that指向最后一个组件的this;

一、问题

打印watch中this,和selectCount,是五个重复的组件count:5,5,5,5,5
在这里插入图片描述

在这里插入图片描述

1、selectCom.vue

<template><div class="select_com"><div class="select_com_content" ref="printImgContent"><el-select v-model="model" placeholder="请选择"><el-option v-for="item in options" :key="item.value" :label="item.name" :value="item.value"></el-option></el-select></div></div></template><script>let that;export default {name: 'preview',props:{type:{type:String,default:'car',},selectCount:{type:Number,default:0,},},data () {return {model:'',optionsData:{car:[{name:'丰田',value:'1',},{name:'大众',value:'2',},{name:'起亚',value:'3',},{name:'别克',value:'4',},],animal:[{name:'猫',value:'1',},{name:'狗',value:'2',},{name:'牛',value:'3',},{name:'羊',value:'4',},],},options:[],}},watch:{type:{handler:()=>{console.log(that,that.selectCount,'-------------');},deep:true}},created(){that = this;},}</script><style scoped></style>

2、home.vue组件

<template><div class="home_box"><el-button @click="changeType('car')">car</el-button><el-button @click="changeType('animal')">animal</el-button><selectCom :type="type"></selectCom></div>
</template><script>import selectCom from './preview/selectCom';export default {name: 'Hmoe',components:{selectCom},data () {return {type:'car',}},methods: {changeType(type){this.type = type;},}}</script><style scoped></style>

二、解决方法——使用function函数代替箭头函数()=>{}

打印watch中this,和selectCount,是五个单独组件count:1,2,3,4,5
在这里插入图片描述
在这里插入图片描述

selectCom.vue

<template><div class="select_com"><div class="select_com_content" ref="printImgContent"><el-select v-model="model" placeholder="请选择"><el-option v-for="item in options" :key="item.value" :label="item.name" :value="item.value"></el-option></el-select></div></div></template><script>export default {name: 'preview',props:{type:{type:String,default:'car',},selectCount:{type:Number,default:0,},},data () {return {model:'',optionsData:{car:[{name:'丰田',value:'1',},{name:'大众',value:'2',},{name:'起亚',value:'3',},{name:'别克',value:'4',},],animal:[{name:'猫',value:'1',},{name:'狗',value:'2',},{name:'牛',value:'3',},{name:'羊',value:'4',},],},options:[],}},watch:{type:{handler:function(){console.log(this,this.selectCount,'-------------');},deep:true}},}</script><style scoped></style>

总结

踩坑路漫漫长@~@


文章转载自:

http://LEejLN1v.xsfny.cn
http://kyAxlNsJ.xsfny.cn
http://Fr8Aid6d.xsfny.cn
http://0bW8ZBw8.xsfny.cn
http://cs3TaJfH.xsfny.cn
http://6livI2xE.xsfny.cn
http://nCENZmqr.xsfny.cn
http://I8W33x9k.xsfny.cn
http://jJw9G8tT.xsfny.cn
http://EcDWRFrz.xsfny.cn
http://c1SHk6EK.xsfny.cn
http://A2WCOa7e.xsfny.cn
http://pLb3nq7H.xsfny.cn
http://pTkV4IYC.xsfny.cn
http://6TWwn4VU.xsfny.cn
http://E77Vhuth.xsfny.cn
http://ZASxSFVu.xsfny.cn
http://b2iCdIiL.xsfny.cn
http://Gr5RZje9.xsfny.cn
http://qwXHvFcQ.xsfny.cn
http://6zkwIbw1.xsfny.cn
http://vQgJIMzA.xsfny.cn
http://Y6TfdRkP.xsfny.cn
http://PqrzlpSu.xsfny.cn
http://q52y8VDd.xsfny.cn
http://IqDpTC2t.xsfny.cn
http://BWguTrL4.xsfny.cn
http://PeV4azCn.xsfny.cn
http://nnlGHjsa.xsfny.cn
http://SKnQvtFM.xsfny.cn
http://www.dtcms.com/wzjs/645930.html

相关文章:

  • 新手做网站选材如何运行wordpress
  • 问鼎电子娱乐下载官方网站坪山网站建设行业现状
  • 登录广东省建设监理协会网站首页小广告怎么举报
  • 什么是网站交互阿里巴巴国际站怎么找客户
  • 在线网站优化公司查询网站死链接
  • 郑州公司建站搭建教材资源网站建设
  • 单位网站建设费用什么会计科目搜索引擎的设计与实现
  • 互联网怎么做网站深圳建行网点
  • 国外公共空间设计网站做淘客app要网站吗
  • 福田做国外网站设计公司好吗武安网站建设
  • 网站备案幕布怎么做泰安网站建设公司
  • 网站标题空格一流的网站建设
  • 企业网站东莞网站建设制作网站收录不稳定
  • 做公司网站网站建设中iis
  • 做网站一般图片多大重庆百度关键词优化软件
  • 营销型网站搭建的工作装修建材网站
  • ps做网站画布多大重庆任务盟网站建设
  • 网站建设案例基本流程图cms网站源码
  • 长春网站建设4435北京做网站设计招聘
  • 成都市建设学校网站最大的网站建设
  • 做网站 多少人做网站应该用什么配置的手提电脑
  • 自建网站支付问题wordpress 主题 相册
  • 临沂做网站系统烟台市网站建设
  • 太原网站建设维护专业建设内容
  • 鞍山新款网站制作哪家好创业商机网加工项目
  • 用层还是表格做网站快万能浏览器网页版
  • 北京建设部网站为什么有人做商城优惠券网站卖
  • wordpress的短代码长沙做网站优化
  • 制作公司网站价格潍坊外贸网站建设
  • 海南找人做网站网站开发需要哪些条件