我在这个问题中做同样的事情,将数据提供给我的模板,编译它并使它看起来像一个文件
var file = 'data:text/html,' + encodeURIComponent(compiled);
Run Code Online (Sandbox Code Playgroud)
一切看起来都很好,模板成功渲染,我得到了我的数据,但现在我的标签停止工作,标签如链接或带有 src 属性的脚本
在这里,我通过 ID MAZ-63171 在 pouchdb 中获取文档并将该文档提供给我的模板:
db.get('MAZ-63171')
.then(function(doc) {
var compileFn = pug.compileFile('./pugTemplates/index.pug', {
pretty: true
});
var compiled = compileFn({doc: doc});
console.log(compiled);
// console.log(doc);
// 'file://' + __dirname + '/pugTemplates/index.pug'
var file = 'data:text/html,' + encodeURIComponent(compiled);
mainWindow.loadURL(file);
})
.catch(function(err) {
console.log(err);
});
Run Code Online (Sandbox Code Playgroud)
在 index.pug 我有这个
doctype html
html(lang="en")
head
title="trucks"
link(rel="stylesheet" href="../node_modules/semantic-ui/dist/semantic.min.css")
//- script window.$ = window.jQuery = require('jquery');
script(src="../node_modules/jquery/dist/jquery.min.js")
script(src="../node_modules/semantic-ui/dist/semantic.min.js")
body
.ui.container
.ui.grid
.four.wide.column
.eight.wide.column
|#{doc._id} …Run Code Online (Sandbox Code Playgroud) 在web.php我有这个
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
],
],
Run Code Online (Sandbox Code Playgroud)
这个文件夹的apache配置像这个php.conf文件
<VirtualHost *:80>
AssignUserId alexzander alexzander
ServerName localhost
DocumentRoot /home/alexzander/Dropbox/study/3year/2/php/
<Directory /home/alexzander/Dropbox/study/3year/2/php/>
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
Order allow,deny
Allow from all
Require all …Run Code Online (Sandbox Code Playgroud)