当前位置:网站首页>Mixin -- mixed
Mixin -- mixed
2022-06-10 20:28:00 【Crmeb Zhongbang Technology】
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
1. 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 mixinimport {demo} from "./mixins"// 2. Configure global blending Vue.mixin(demo)Vue.config.productionTip = falsenew 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 : yu27Baidu 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 floating point number storage form
- 「Bug」问题分析 RuntimeError:which is output 0 of ReluBackward0
- The national advanced computing industry innovation (Yichang) center was officially launched and jointly operated by Zhongke Shuguang and Shengzhe technologies
- How to realize face verification quickly and accurately?
- Hm3416h buck IC chip pwm/pfm controls DC-DC buck converter
- 补水仪108K加湿器开发方案_单片机_NY8A051F_单片机开发设计开发
- 性能测试方案(计划)模板
- HW blue team intermediate interview reply
- 用一个性能提升了666倍的小案例说明在TiDB中正确使用索引的重要性
- Fs2117 boost IC output 5v2.4a synchronous rectification
猜你喜欢

During the college entrance examination this year, all examination sites were in good order, and no sensitive cases affecting safety occurred

Trilogy to solve the problem of playing chess first and then

Zabbix_原理架构-安装部署-自定义监控

Basic instructions for ads and AXD

It took 2 years, 442 authors and 132 institutions! Google released the new benchmark big bench for language model evaluation. 204 tasks comprehensively evaluated the language model ability, with paper

【技术碎片】重名文件 加后缀重命名过滤实现

Redis cluster form - sentry mode cluster and high availability mode cluster - redis learning notes 003

SBC芯片35584数据手册预调节器翻译

国庆期间给大家推荐一个可能会成为2019最佳的CRUD工具

20192407 2021-2022-2 《网络与系统攻防技术》实验八实验报告
随机推荐
玩艺术也得学数学?
FS2117升压IC输出5V2.4A同步整流
Uni app custom navigation
[Legendre] polynomial
腾讯云数据库TDSQL-大咖论道 | 基础软件的过去、现在、未来
SBC chip 35584 data manual pre regulator translation
Solving Bob's survival problem by trilogy routine
The new audio infinix machine appears in the Google product library, and Tecno CaMon 19 is pre installed with Android 13
Bit operation topic
table设置超出部分隐藏,鼠标移上去显示全部
When can Flink support the SQL client mode? When can I specify the applicati for submitting tasks to yarn
Solution to the problem that JLINK CDC UART driver cannot be installed normally under win7 system
刷脸认证如何实现人脸又快又准完成校验?
暗黑破坏神不朽数据库怎么用 暗黑破坏神手游不朽数据库使用方法
First batch! Sinomenine has passed CWPP capability assessment and inspection of Xintong Institute
补水仪108K加湿器开发方案_单片机_NY8A051F_单片机开发设计开发
Standing at such a time node today, we may have a clearer understanding of the industrial Internet
ResourceNotFoundException : Unable to find resource
Soft deletion of data - when? How to realize it?
[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service