当前位置:网站首页>Mixin -- mixed
Mixin -- mixed
2022-06-10 19:45:00 【CRMEB】
mixin yes vue One of the technologies of component reuse function It can encapsulate the properties and methods that appear repeatedly in multiple components to facilitate multiple calls
Use
- Mixing is to encapsulate the attributes and methods used by components many times
Create a new one mixin The folder of is used to contain the mixed encapsulation
export let demo={
methods:{
fun(){
console.log(" Hello !!!!!!")
}
},
data(){
return {
}
},
computed:{
}
}
call
The whole thing is in --mixin
Careful use may cause code pollution 、
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 1. quote mixin
import {
demo} from "./mixins"
// 2. Configure global blending
Vue.mixin(demo)
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
To mix in partially --mixins
<template>
<div class="about">
<h1>This is an about page</h1>
<!-- 3. You can use the mixed content as you want -->
<button @click="fun()"> Click on me to call the mixed method --{
{
text}}</button>
</div>
</template>
<script>
// 1. Reference blending
import {
demo} from "@/mixins"
export default {
// 2. Call blending
mixins:[demo]
}
</script>
Vue Hook functions of the life cycle
beforeCreate The instance is ready to be created ( Data observation and initialization events have not been executed yet )
created Instance creation finished ( Completed the observation of data attribute Methods are also initialized But the page doesn't show the rendering )
beforeMount Template ready to render ( In preparation for template The template is hung in the page Ready to compile page content )
mounted Call... Immediately after the page is loaded ( The page was successfully mounted Page dom The content is also generated )
beforeUpdate Start preparing for updates ( Call when the data is ready to be updated At this time, it is still in the preparation stage of data construction and update )
updated Updated completely ( The data has been successfully displayed on the page dom Has been updated in )
beforeDestroy Start preparing for destruction (vue Examples still work )
Destroyed Destroyed
Custom instruction hook function
bind : Binding instructions to elements Only once ;
inserted : The element bound with the instruction is called when inserting the page display
update: Call when all nodes are updated
componentUpdate: The node of the component where the instruction is located and all its own child nodes have been updated Calling
unbind: Call when contacting the binding of an instruction and an element Only once
The source code attachment has been packaged and uploaded to Baidu cloud , You can download it yourself ~
link : https://pan.baidu.com/s/14G-bpVthImHD4eosZUNSFA?pwd=yu27
Extraction code : yu27
Baidu cloud link is unstable , It may fail at any time , Let's keep it tight .
If Baidu cloud link fails , Please leave me a message , When I see it, I will update it in time ~
Open source address
Code cloud address :
http://github.crmeb.net/u/defu
Github Address :
http://github.crmeb.net/u/defu
边栏推荐
- [C language] accidentally write a bug? Mortals teach you how to write good code [explain debugging skills in vs]
- Logback排除指定包/类/方法日志输出
- 马斯克称自己不喜欢做CEO,更想做技术和设计;吴恩达的《机器学习》课程即将关闭注册|极客头条
- Mysql8.0 (summary of new features)
- TiDB - 快速入门,集群搭建
- Analysis of optical storage direct flexible power distribution system
- Basic model and properties of SAR echo signal
- Zabbix Server Trapper远程代码执行漏洞(CVE-2017-2824)
- 全数字时代,企业IT如何完成转型?
- 2022.05.26 (lc_1143_longest common subsequence)
猜你喜欢

MicroNet实战:使用MicroNet实现图像分类

Developers changing the world - Yao Guang teenagers playing Tetris

2022.05.25 (lc_718_longest repeating subarray)

【 Web 】 page d'accueil personnelle 】 Programme d'études 】 albums de photos 】 babillard d'information 】

This article introduces you to j.u.c's futuretask, fork/join framework and BlockingQueue

618大促将至,用AI挖掘差评,零代码实现亿级评论观点情感分析

c(指针02)
![[C language] accidentally write a bug? Mortals teach you how to write good code [explain debugging skills in vs]](/img/34/6f254e027e5941bb2c3462b665c3ba.png)
[C language] accidentally write a bug? Mortals teach you how to write good code [explain debugging skills in vs]

禁止摆烂,软件测试工程师从初级到高级进阶指南,助你一路晋升

APICloud可视化开发新手图文教程
随机推荐
2022.05.27 (lc_647_palindrome substring)
云图说|每个成功的业务系统都离不开APIG的保驾护航
Super simple course design SSM student management system (including simple addition, deletion, modification and query of source code)
DDD landing practice repeat record of theoretical training & Event storm
掌握高性能计算前,我们先了解一下它的历史
2022最强版应届生软件测试面试攻略,助你直通大厂
Esp8266 system environment setup
Multi channel signal data compression storage
恭喜 | 医学院那洁课题组通过多组学分析揭示JUNB在体外分化人造血祖细胞过程中的功能
DataScience&ML:金融科技领域之风控之风控指标/字段相关概念、口径逻辑之详细攻略
Monotonic stack structure
【web】個人主頁web大作業「課錶」「相册」「留言板」
2022 software test interview strategy for the strongest version of fresh students to help you get directly to the big factory
Computer: successfully teach you how to use one trick to retrieve the previous password (the password once saved but currently displayed as ******)
MySQL advanced Chapter 1 (installing MySQL under Linux) [i]
Lingo12 software download and lingo language introduction resources
Apicloud visual development - one click generation of professional source code
2022.05.24 (lc_674_longest continuous increasing sequence)
[advanced C language] data storage [part I] [ten thousand words summary]
大厂是怎么写数据分析报告的?