当前位置:网站首页>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 边栏推荐
- Can [C language - user defined type] be adjusted like this?
- 见鬼,U盘空间怎么少了,原来是EFI分区搞的鬼,删除它
- 【萌新解题】四数之和
- 009 面试题 SQL语句各部分的执行顺序
- Which company is better in data filling and report presentation? Yixin ABI gives you the answer
- 44、使用OrienMask进行实例分割目标检测,并进行mnn部署和ncnn部署
- 滑動窗口最大值問題
- MySQL CPU usage is soaring. How to locate who is occupying it
- Explain the operation of C language file in detail
- High performance pxie data preprocessing board based on kinex ultrascale series FPGA (ku060 +fmc sub card interface)
猜你喜欢

Read the paper: temporary graph networks for deep learning on dynamic graphs

Oracle - 锁

C语音 杨氏矩阵 · 左旋字符串 · 判断字符串是否旋转
![Can [C language - user defined type] be adjusted like this?](/img/f0/313cd86d875f6d1ffc516ab8de3477.png)
Can [C language - user defined type] be adjusted like this?

2021.07.13【B站】是这样崩的

Scheduled tasks, VIM directly creates and modifies users

C - usage of this

Preview of authtalk phase I | comprehensive dismantling of multi tenant solutions

1. Basic concepts of DBMS

国内顶尖专家集聚广州,探讨健康医疗数据安全应用
随机推荐
Qchartview overwrites the previous control when it is added in qgridlayout
【萌新解题】四数之和
Explain the operation of C language file in detail
SBOM(Software Bill of Materials,软件物料清单)
Behind the high salary of programmers' operation and maintenance
ORA-00054
DMA方式的特点
UCAS. Deep learning Final examination questions and brief thinking analysis
Sub database and sub table
Labview32-bit and 64 bit compatibility
Code runner for vs code, with more than 40million downloads! Support more than 50 languages
【MQTT从入门到提高系列 | 07】MQTT3.1.1之链路保活及断开
Practice of tDesign in vitest
Compositionapi component development paradigm
Is it safe to open a fund account online now?
暑期第三周总结
Abstract classes and derived classes
PKI:TLS握手
Damn it, why is there less space on the USB flash drive? It's the EFI partition. Delete it
TDesign 在 vitest 的实践