我试图使用 pug 语法在 html 页面上显示 svg 图标,但不起作用
这是代码
span.icon
svg(width="24px", height="24px")
use(xlink:href="../../../images/svg/glass.svg")
Run Code Online (Sandbox Code Playgroud) 我正在使用 axios CDN 链接,但它给出了此错误
Refused to load the script 'https://unpkg.com/axios/dist/axios.min.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
我正在使用哈巴狗模板引擎。这是我的 base.pug 代码:
doctype html
html
head
meta(charset='UTF-8')
meta(name='viewport' content='width=device-width, initial-scale=1.0')
title Natours |#{title}
link(rel='stylesheet' href='/css/style.css')
link(rel='shortcut icon' type='image/png' href='/img/favicon.png')
link(rel='stylesheet' href='https://fonts.googleapis.com/css?family=Lato:300,300i,700')
body
//header
include _header
//content
block content
h1 this is a placeholder
//footer
include _footer
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
script(src='/js/login.js')
Run Code Online (Sandbox Code Playgroud)
这是我的login.js
const login=async (email,password)=>{
try{ …Run Code Online (Sandbox Code Playgroud) 我把一个数组传给了玉
router.get('/index', function(req, res){
var users = ["A","B","C"];
res.render('index', {user: users})
});
Run Code Online (Sandbox Code Playgroud)
//我在玉中得到什么
li #{user}
<li>a,b,c</li>
li #(user[0])
<li>a</li>
Run Code Online (Sandbox Code Playgroud)
如何在不必编写用户[0],用户[1],用户[2]的情况下获得此代码?
<li>A</li>
<li>B</li>
<li>C</li>
Run Code Online (Sandbox Code Playgroud)
我试过跟随,但我有错误.
#{user}中的
每个项目用户中的每个项目
我正在创建一个Node.js Web应用程序,我不确定是否使用AngularJS(或其他客户端模板引擎,如Ember或Backbone)来显示数据库中的数据或生成服务器端的页面(与玉)然后发送它.使用一种方法与另一种方法有显着的好处吗?
Angular确实增加了额外的复杂性,但与此同时我担心在服务器端生成页面时所涉及的性能损失.
这是我的预期结果:
<a>
<button class="btn btn-tomato mx-auto" type="button" style="width:50%; white-space: normal; opacity:0.8;">Button text</button>
</a>
Run Code Online (Sandbox Code Playgroud)
所以我这样写我的哈巴狗:
a
button.btn.btn-tomato.mx-auto(type='button', style='width:50%; white-space: normal; opacity:0.8')
Run Code Online (Sandbox Code Playgroud)
但是,结果是这样的:
<a></a>
<button class="btn btn-tomato mx-auto" type="button" style="width:50%; white-space: normal; opacity:0.8;">Button text</button>
Run Code Online (Sandbox Code Playgroud)
该<button>在不<a>。你能告诉我如何解决吗?谢谢。