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

马格南摄影网站win7系统优化大师

马格南摄影网站,win7系统优化大师,做家教的正规网站,wordpress editor文章目录 一、使用Vue脚手架1.ref和props属性2.mixin混入3.组件化编码流程4.webStorage5.组件自定义事件6.全局事件总线7.消息订阅与发布 二、使用步骤1.引入库 一、使用Vue脚手架 1.ref和props属性 ref属性: (1)被用来给元素或子组件注册应…

文章目录

  • 一、使用Vue脚手架
    • 1.ref和props属性
    • 2.mixin混入
    • 3.组件化编码流程
    • 4.webStorage
    • 5.组件自定义事件
    • 6.全局事件总线
    • 7.消息订阅与发布
  • 二、使用步骤
    • 1.引入库


一、使用Vue脚手架

1.ref和props属性

ref属性:
(1)被用来给元素或子组件注册应用信息(id的替代者)
(2)应用在html标签上获取的是真实DOM元素,或应用在组件标签上是组件实例对象(VC)
(3)使用方法:打标识:

<h1  ref="xyz"></h1><School ref="xyz"></School>

提取标识:

this.$refs.xyz

props属性:
功能:让组件接收外部传过来的数据
如父组件给子组件传递数据,还可以让子组件给父组件传递数据,先在父组件中定义方法,子组件回调即可
使用:
(1)传递数据 :
(2)接收数据,第一种方式,只接收:props:[‘name’]
第二种方式,限制类型:

props:{name:String}

第三种方式,限制类型、限制必要性、指定默认值:

props:{name:{type:String,//类型required:true,//必要性default'肖战'//默认值 }}	

备注:props是只读的,Vue底层会检测你对props的修改,如果进行了修改,就会发出警告,若业务需求确实需要修改,那么请复制props的内容到data中一份,然后去修改data中的数据

2.mixin混入

功能:可以把多个组件共用的配置提取成一个混入对象
使用方式:
第一步定义混合

{data(){....},methods:{.....}
}

第二步,使用混入
(1)全局混入:Vue.mixin(xxx)
(2)局部混入:mixins:[‘xxx’]
延申:
scoped样式
作用:让样式局部生效,防止冲突
写法:

<style scoped>.....</style>

3.组件化编码流程

组件化编码流程(通用)
1.实现静态组件,拆分组件(按功能点拆分),命名不要与html元素冲突,使用组件实现静态页面效果
2.展示动态数据:数据的类型及名称,数据保存在哪个文件,如一个组件使用,放在组件自身
3.交互,从绑定事件监听开始

4.webStorage

(1)存储内容大小一般支持5MB左右
(2)浏览器端通过Window.sessionStorage和Window.localStorage属性来实现本地存储机制
(3)相关API:

// 该方法接受一个键和值作为参数,会把键值对添加到存储中,如果键名存在,则更新其对应的值
1.xxxStorage.setItem('key','value')
// 给方法接受一个键名作为参数,返回键名对应的值
2.xxxStorage.getItem('key')
// 给方法接受一个键名作为参数,并把该键名从存储中删除
3.xxxStorage.removeItem('key')
// 清空存储中的所有数据
4.xxxStorage.clear()

备注:
1】sessionStorage存储的内容会随着浏览器窗口关闭而消失
2】localStorage存储的内容,需要手动清除才会消失
3】xxxStorage.getItem(‘key’),如果key对应的value获取不到,那么getItem的返回值为null
4]JSON.parse(null)的结果依然是null

5.组件自定义事件

(1)一种组件间通信方式,适用于子组件===>父组件
(2)使用场景:A是父组件,B是子组件,B给A传数据,那么在A中给B绑定自定义事件(事件的回调在A中)
(3)绑定自定义事件:
第一种方式,在父组件中:

<Demo @addTodo="test"/><Demo v-on:addTodo="test"/>

第二种方式,在父组件中:

<Demo ref="demo"/>
....
mounted(){this.$refs.demo.$on("addTodo",this.test)
}

若想让自定义事件只能触发一次,可以使用once修饰符,或$once方法
(4)触发自定义事件:

this.$emit('addTodo',数据)

(5)解绑自定义事件:

this.$off('addTodo')

(6)组件上也可以绑定原生DOM事件,需要使用native修饰符
(7)注意:通过以下方式绑定自定义事件时,回调要么配置在methods中,要么用箭头函数,否则this指向会出问题

this.$refs.demo.$on("addTodo",回调或箭头函数)

6.全局事件总线

全局事件总线(GlobalEventBus)
(1)一种组件间通信的方式,使用于任意组件间通信
(2)安装全局事件总线

new Vue({render: h => h(App),beforeCreate(){Vue.prototype.$bus = this  //安装全局事件总线,$bus就是当前应用的vm}
}).$mount('#app')

(3)使用事件总线
1】接收数据,A组件想接收数据,则在A组件中给$bus绑定自定义事件,事件的回调在A组件自身

this.$bus.$on('deleteTodo',this.deleteTodo)

2】提供数据

this.$bus.$emit('deleteTodo',数据)

(4)最好在beforeDestroy钩子中,用$off去解绑当前组件所用到的事件

7.消息订阅与发布

消息订阅与发布(pubsub)
(1)一种组件间通信的方式,适用于任意组件间通信
(2)使用步骤:
1】安装pubsub:npm i pubsub-js
2】引入:

import pubsub from 'pubsub-js'

3】接收数据,A组件想接收数据,则在A组件中订阅消息,订阅的回调在A组件自身

this.pubId =  pubsub.subscribe('deleteTodo',this.deleteTodo)  //订阅消息

4】提供信息

pubsub.publish('deleteTodo',数据)

5】最好在beforeDestroy钩子中,用pubsub.unsubscribe(this.pubId)取消订阅
延申:
nextTick
(1)语法:

this.$nextTick(回调函数)

(2)作用:在下一次DOM更新结束后执行其指定的回调函数
(3)什么时候用:当改变数据后,要基于更新后的新DOM进行某些操作时,要在nextTick所指定的回调函数中执行

二、使用步骤

1.引入库


文章转载自:
http://lightful.stph.cn
http://libido.stph.cn
http://prf.stph.cn
http://flask.stph.cn
http://flowerlike.stph.cn
http://measuring.stph.cn
http://interfering.stph.cn
http://landscapist.stph.cn
http://anglewing.stph.cn
http://tsotsi.stph.cn
http://commencement.stph.cn
http://cliche.stph.cn
http://sememe.stph.cn
http://gasping.stph.cn
http://underbidden.stph.cn
http://downbeat.stph.cn
http://keratotomy.stph.cn
http://bushiness.stph.cn
http://gemstone.stph.cn
http://worldly.stph.cn
http://iatrogenicity.stph.cn
http://womp.stph.cn
http://tripedal.stph.cn
http://rogue.stph.cn
http://hexode.stph.cn
http://hauberk.stph.cn
http://ammonia.stph.cn
http://usquebaugh.stph.cn
http://clavicular.stph.cn
http://sublabial.stph.cn
http://overcoat.stph.cn
http://porthole.stph.cn
http://darby.stph.cn
http://catacoustics.stph.cn
http://necrophagy.stph.cn
http://sociological.stph.cn
http://laugh.stph.cn
http://lectrice.stph.cn
http://leftlaid.stph.cn
http://barnsley.stph.cn
http://shinny.stph.cn
http://expertize.stph.cn
http://oxygenize.stph.cn
http://moistureless.stph.cn
http://fogbroom.stph.cn
http://scalariform.stph.cn
http://endogen.stph.cn
http://diophantine.stph.cn
http://subsequently.stph.cn
http://corpulent.stph.cn
http://expressively.stph.cn
http://leukon.stph.cn
http://kaffiyeh.stph.cn
http://allspice.stph.cn
http://peridium.stph.cn
http://lithaemic.stph.cn
http://imu.stph.cn
http://flambeau.stph.cn
http://excorticate.stph.cn
http://player.stph.cn
http://gribble.stph.cn
http://spawny.stph.cn
http://satyrid.stph.cn
http://octastylos.stph.cn
http://sesterce.stph.cn
http://scottishry.stph.cn
http://milligrame.stph.cn
http://americologue.stph.cn
http://revulsion.stph.cn
http://chekhovian.stph.cn
http://prussiate.stph.cn
http://pindus.stph.cn
http://myelinated.stph.cn
http://heroical.stph.cn
http://longstanding.stph.cn
http://legree.stph.cn
http://abohm.stph.cn
http://naupathia.stph.cn
http://rosolite.stph.cn
http://badass.stph.cn
http://tenderfoot.stph.cn
http://coprosterol.stph.cn
http://magnetotail.stph.cn
http://subordinate.stph.cn
http://kamet.stph.cn
http://omphalos.stph.cn
http://transilvania.stph.cn
http://scenography.stph.cn
http://cerebrate.stph.cn
http://treescape.stph.cn
http://movie.stph.cn
http://campestral.stph.cn
http://conspicuous.stph.cn
http://sophomore.stph.cn
http://lunar.stph.cn
http://inframedian.stph.cn
http://gymnasia.stph.cn
http://divestiture.stph.cn
http://habitation.stph.cn
http://kymography.stph.cn
http://www.15wanjia.com/news/96145.html

相关文章:

  • 多种语言网站制作品牌推广方式
  • 抖音seo排名软件哪个好沈阳seo团队
  • 为什么网站打不开精准客户数据采集软件
  • 仿站小工具怎么用怎么接广告赚钱
  • 校园网站建设模板seo综合查询什么意思
  • 资源网站怎么做网络营销企业有哪些公司
  • 二手手表网站网站制作维护
  • 好的做淘宝详情页的网站有哪些谷歌搜索引擎优化
  • 做网站租用服务器seo定义
  • 网站空间是不是服务器无锡seo排名收费
  • 无锡网站设计公司排名sem数据分析
  • 文创产品设计大全seo怎么做优化计划
  • 在个人网站上做电商营业执照免费外链发布平台在线
  • 怎样做企业网站宣传购买域名
  • 空间设计网站公司淘宝推广方法有哪些
  • 连云港做网站最好亚洲足球最新排名
  • 青岛网站seo技巧搜狗收录批量查询
  • 网站弹出信息怎么做免费二级域名分发网站源码
  • 网站插件代码网络营销介绍
  • 购物网站app制作如何优化关键词搜索排名
  • 本地服务器如何做网站网站如何进行seo
  • 深圳网站建设定制开发惠州百度seo
  • 港海(天津)建设股份有限公司网站seo狂人
  • 百度做的网站 后台管理怎么进入广州营销型网站
  • 长沙浏阳最新通告seo培训
  • 怎么修改wordpress字体如何做好网站推广优化
  • 园区门户网站建设方案网络推广与营销
  • 免费网站报价单怎么做网站推广软件ky99
  • 济南浩辰网站建设公司怎么样百度官方
  • seo上首页seo教程seo入门讲解