vue中如何实现变量和字符串拼接
作者:xqnode 时间:2024-04-30 10:21:22
整理文档,搜刮出一个vue中如何实现变量和字符串拼接的代码,稍微整理精简一下做下分享。
在data中定义变量:
data() {
return {
a: 'A'
}
}
如何通过按钮点击实现字符串和变量a的拼接呢?
<button @click='showMsg'></button>
//vue
methods: {
showMsg() {
alert(`获取了${a}`);
}
}
注意alert()里不是单引号,而是两个 ` 号(esc下面的按键)。
点击按钮出现
来源:http://blog.csdn.net/xqnode/article/details/61202270
标签:vue,字符串,变量
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
vue使用代理解决请求跨域问题详解
2024-05-10 14:15:33
Django 创建/删除用户的示例代码
2022-09-30 08:59:29
![](https://img.aspxhome.com/file/2023/1/70761_0s.png)
python热力图实现简单方法
2023-10-28 06:14:41
卸载tensorflow-cpu重装tensorflow-gpu操作
2022-07-31 12:46:13
![](https://img.aspxhome.com/file/2023/0/131650_0s.jpg)
利用PyQt5制作一个豆瓣电影信息查看器
2021-03-05 05:57:28
![](https://img.aspxhome.com/file/2023/7/109437_0s.png)
Python 通过爬虫实现GitHub网页的模拟登录的示例代码
2022-04-27 00:26:39
![](https://img.aspxhome.com/file/2023/4/86564_0s.jpg)
Python中的lambda和apply用法及说明
2023-08-12 14:56:46
sql server中错误日志errorlog的深入讲解
2024-01-23 11:57:58
![](https://img.aspxhome.com/file/2023/2/104072_0s.png)
无阻塞加载脚本分析[全]
2024-04-17 10:25:35
Python numpy.zero() 初始化矩阵实例
2021-04-06 01:52:46
通过JavaScript实现扑克牌游戏的示例代码
2024-05-13 09:20:40
![](https://img.aspxhome.com/file/2023/7/125927_0s.jpg)
golang NewRequest/gorequest实现http请求的示例代码
2024-04-30 10:03:26
MySQL关于ERROR 1290 (HY000)报错解决方法
2024-01-21 19:50:23
javascript 文档的编码问题解决
2024-04-22 22:45:22
PHP中isset()和unset()函数的用法小结
2023-11-19 14:19:24
Django项目中model的数据处理以及页面交互方法
2022-12-26 20:12:25
![](https://img.aspxhome.com/file/2023/5/101655_0s.jpg)
Python之捕捉异常详解
2022-06-10 02:27:30
![](https://img.aspxhome.com/file/2023/2/110052_0s.png)
在vue项目中使用Jquery-contextmenu插件的步骤讲解
2023-07-02 17:08:29
![](https://img.aspxhome.com/file/2023/6/139946_0s.png)
Vue + Node.js + MongoDB图片上传组件实现图片预览和删除功能详解
2024-05-10 14:14:56
![](https://img.aspxhome.com/file/2023/9/126539_0s.jpg)
php基础知识:类与对象(5) static
2023-07-24 03:01:30