当前位置:网站首页>Tips for using setup
Tips for using setup
2022-07-19 15:01:00 【InfoQ】
One 、setup Characteristics and functions of functions
Two 、setup Attention points of function
usage 1: combination ref Use
<template>
<div id="app">
{{name}}
<p>{{age}}</p>
<button @click="plusOne()">+</button>
</div>
</template>
<script>
import {ref} from "vue"
export default {
name:"app",
data(){
return {
name:"xiaosan"
}
},
setup(){
const name =ref(" Little four ")
const age=ref(18)
function plusOne(){
age.value++ // Want to change the value or get the value must .value
}
return { // Must return Can only be used in the template
name,age,plusOne
}
}
}
</script>
Copy code usage 2: The code segment
importuseAfrom "./a";
importuseBfrom "./b";
importuseCfrom "./c";
exportdefault {
setup(props) {
let { a, methodsA } = useA();
let { b, methodsB } = useA();
let { c, methodsC } = useC();
return {
a,
methodsA,
b,
methodsB,
c,
methodsC
}
}
}
Copy code 边栏推荐
- MySQL index (II)
- Explain the operation of C language file in detail
- [mqtt from getting started to improving series | 06] subscribe subscription workflow of mqtt3.1.1
- Practice of tDesign in vitest
- 跨域与CORS
- Icml2022 | geometric multimodal comparative representation learning
- 模块1 作业
- 009 execution sequence of SQL statement of interview questions
- 3438. 数制转换
- Google Earth engine - Classification and processing of UAV images
猜你喜欢

Gradle introduction notes

Abstract classes and derived classes

Chang'an chain learning research - storage analysis wal mechanism

Explain the operation of C language file in detail

MySQL view

Qchartview overwrites the previous control when it is added in qgridlayout

Icml2022 | geometric multimodal comparative representation learning

session management

6U VPX high speed signal processing board based on ku115+mpsoc (xcku115 + zu9eg +dsp)

Top domestic experts gathered in Guangzhou to discuss the safety application of health care data
随机推荐
MySQL CPU usage is soaring. How to locate who is occupying it
Data consistency between redis and MySQL
One article, teach you to achieve single sign on
Vscode download historical version
天勤第九章课后习题代码
现在网上办理基金开户,身份证信息安全吗?
High performance pxie data preprocessing board based on kinex ultrascale series FPGA (ku060 +fmc sub card interface)
揭开服务网格~Istio Service Mesh神秘的面纱
见鬼,U盘空间怎么少了,原来是EFI分区搞的鬼,删除它
MySQL index (II)
[flask introduction series] exception handling
Problème de la valeur maximale de la fenêtre coulissante
Scheduled tasks, VIM directly creates and modifies users
Learning records [email protected] Moveactivityidto task fallback special case analysis
Icml2022 | géométrie multimodale Contrastive Representation Learning
Istio XDS配置生成实现
MySQL storage functions and triggers
Sliding window maximum problem
Which company is better in data filling and report presentation? Yixin ABI gives you the answer
Sub database and sub table