sách gpt4 ai đã đi

Trong Jade, tại sao đôi khi tôi có thể sử dụng các biến như vậy và đôi khi phải đặt chúng trong #{......}?

In lại 作者:行者123 更新时间:2023-12-02 03:29:44 26 4
mua khóa gpt4 Nike

看下面的代码

        for story in book 
if story.title.length < 140
- var storyTitle = story.title;
khác
- var storyTitle = story.title.substring(0, 140) + '...';

.tiles
a(href= 'http://' + story.link)
img(src=story.thumbnail, width='150', height='150')
p Title: #{storyTitle}
p Date: #{story.time}
p Author: #{story.authorName}

这对我有用。然而让我感到困惑的是,有时我可以使用 story.attribute 而在某些地方我必须使用 #{story.attribute}。

例如。如果我使用这条线

p Title: storyTitle

没有 mustache ,它只是在浏览器中打印字符串“Title: storyTitle”。

另一个例子,如果我使用 img(src=#{story.thumbnail}, width='150', height='150'),它不起作用,我得到一个 html string (%20%20... something...) 在我的浏览器中。

那给了什么?

1 Câu trả lời

简单的说

After equal sign (=) and inside code blocks no curly braces. Everywhere else use #{}.

关于express - 在 Jade 中,为什么有时我可以按原样使用变量而有时必须将它们包含在#{......} 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14709560/

26 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com