JavaScript全栈教程参考源码
michaelliao / learn-javascript Goto Github PK
View Code? Open in Web Editor NEWJavaScript全栈教程参考源码
Home Page: https://www.liaoxuefeng.com/wiki/1022910821149312
License: Apache License 2.0
JavaScript全栈教程参考源码
Home Page: https://www.liaoxuefeng.com/wiki/1022910821149312
License: Apache License 2.0
您好,博客停止更新了吗,以前经常关注
你好廖老师
关于你的view-koa项目
不太明白为什么在templating.js中这样写
function templating(path, opts) { var env = createEnv(path, opts); return async (ctx, next) => { ctx.render = function (view, model) { ctx.response.body = env.render(view, Object.assign({}, ctx.state || {}, model || {})); ctx.response.type = 'text/html'; }; await next(); }; }
请问这段代码是怎么使controller里面的ctx添加render()函数的?
product的数据通过接口请求数据库再返回的话,此时controllers里就拿不到返回的数据了。
view-koa下
// static file support: if (! isProduction) { let staticFiles = require('./static-files'); app.use(staticFiles('/static/', __dirname + '/static')); }
为什么要这么做的呢?
为什么不是production才导入staticFiles呢?
本机node环境为4.4.1版本,按照源代码直接执行mocha命令后,报错如下:
/Users/Jacksun/Sites/Koa2/hello.js:6
module.exports = function(...rest){
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/Jacksun/Sites/Koa2/test/hello-test.js:8:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /Users/Jacksun/Sites/Koa2/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/Jacksun/Sites/Koa2/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/Users/Jacksun/Sites/Koa2/node_modules/mocha/lib/mocha.js:485:10)
at Object.<anonymous> (/Users/Jacksun/Sites/Koa2/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
首先是,当我跟着课程写db.js,不管是参照课程里的,还是参照github上的,都会报错:
sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security,
我看有篇CSDN写了有关该课程是因为执行函数后面忘了写;分号.但是我几番检查,该处代码完全没有像([{+;之类的问题,而且问题出现在new sequellize里.除非是在new里声明operatorsAliases: false,否则一直warning.原因到底是因为什么?
其二是,在github上的代码,添加了课程里面没有的,当创建一个orm后会输出的console.log,这这里面有一些循环处理,但是 if (v instanceof dbType) 这句话一直报TypeError: Function has non-object prototype 'undefined' in instanceof check,应该是还要在嵌套一个if判断v的instanceof指向吧?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.