我正在使用"sails": "~0.12.1"
.我正在连接到mysql数据库.我可以连接到MySQL Workbench上的数据库,因此数据库正在运行.当我尝试sails lift
收到此错误时:
info: Starting app...
error: A hook (`orm`) failed to load!
error: SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at /node_modules/include-all/index.js:129:29
at Array.forEach (native)
at requireAll (/node_modules/include-all/index.js:44:9)
at buildDictionary (/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14)
at Function.module.exports.optional (/node_modules/sails/node_modules/sails-build-dictionary/index.js:160:9)
at Hook.loadModels (/node_modules/sails/lib/hooks/moduleloader/index.js:344:23)
at Hook.wrapper [as loadModels] (/node_modules/sails/node_modules/lodash/index.js:3095:19)
at Array.async.auto.models (/node_modules/sails/lib/hooks/orm/load-user-modules.js:20:23)
at /node_modules/sails/node_modules/async/lib/async.js:591:38
Run Code Online (Sandbox Code Playgroud)
更新:config/connections.js
module.exports.connections = {
mysql: {
adapter: 'sails-mysql',
host: 'localhost', …
Run Code Online (Sandbox Code Playgroud) 我想中断Enter key
并停止将html代码注入ContentEditable div。我当前的代码不起作用,因为它不会中断Enter key
。但是,如果我键入内容,请按Enter键,然后再次键入,它将删除内部html元素。但是,这不是我想要的。我希望元素在我按Enter时不进入ContentEditable div,而不必将其剥离。
我基本上是用这个作为input that scales with its content
。如果有更好的方法可以进行此操作,请告诉我!
import ReactDOM from 'react-dom'
export default class MyInput extends React.Component {
componentWillReceiveProps(nextProps) {
this.setState({value: nextProps.html});
}
shouldComponentUpdate(nextProps){
return nextProps.html !== ReactDOM.findDOMNode(this).innerHTML;
}
componentDidUpdate() {
if ( this.htmlEl && this.props.html !== this.htmlEl.innerHTML ) {
this.htmlEl.innerHTML = this.props.html;
}
}
emitChange(){
var html = ReactDOM.findDOMNode(this).innerHTML;
// regex to remove tags created after pressing enter
value = value.replace(/<div>/g, '');
value = value.replace(/<\/div>/g, '');
value = value.replace(/<br>/g, …
Run Code Online (Sandbox Code Playgroud)