``的用法,还有$的用法?

小程序 文章 2020-09-04 09:01 1374 0 全屏看文

AI助手支持GPT4.0

``的用法,还有$的用法?``The usage, and the usage of $?

``的用法,还有$的用法?

一路跟着腾讯云的教程学过来,下图中的url右边``里面应该是一个字符串,但字符串里有计算的表达式(取res._id的值)在表达式前面加一个$就是表示计算这个表达式吗?教程里面一直没有提过这方面的知识,还有这个撇号(``)的用法,请各位DX提供一下教程或者解释一下。从网上没有百度到相关知识。

Follow the tutorial of Tencent cloud all the way. There should be a string in the URL on the right in the figure below, but there is a calculated expression in the string (take res_ Is adding a $before the expression to evaluate the expression? The tutorial has not mentioned this knowledge, but also the use of the apostrophe ('). Please provide a tutorial or explanation for DX. No Baidu from the Internet to the relevant knowledge.

回答:

Stephen:

这不是微信提供的语法自然不会在教程里体现。这是JS的功能,准确的说是 JavaScript 中 ES6 版本的特性 —— “模板字符串”,可以当作普通字符串使用,也可以用来定义多行字符串,或者在字符串中嵌入变量。一般用于解决一段文本出现需要变量动态组合时,变量过多拼接带来的繁琐和不方便。详细的介绍可以参考:https://es6.ruanyifeng.com/#docs/string#%E6%A8%A1%E6%9D%BF%E5%AD%97%E7%AC%A6%E4%B8%B2

Admin²⁰²⁰:

这个是es6的写法


谋谋谋:

没错 楼下正解

-EOF-

AI助手支持GPT4.0