我想在组件之间共享一个对象,类代码在那里。
class IDE {
constructor(id) {
config.set('basePath', 'static/js/ace');
this.aceEditor = edit(id);
this.aceSession = this.aceEditor.session;
this.aceSession.setMode("ace/mode/javascript");
this.aceEditor.setTheme('ace/theme/monokai');
this.aceEditor.setShowPrintMargin(false);
}
setMode() {
}
}
Run Code Online (Sandbox Code Playgroud)
有人告诉我使用 vuex,这是我的商店模块代码。
export default{
namespaced:true,
state:{
ide:null
},
mutations:{
setIDE(state,ide){
state.ide = ide
}
},
getters:{
getIDE: state =>{return ide}
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试在商店中获取我的 ide 对象时
this.$store.state.global.ide.__proto__.setMode('ace/mode/java')
铬总是告诉我
TypeError: Cannot read property 'setMode' of undefined
所以我在开发工具中查看我的代码
ide.setMode()
?我想捆绑我的 vue ssr server.js
,将所有内容包含node_modules
到一个文件中
我已经将服务器和客户端代码构建到dist/
文件夹中
现在,我想在 docker 镜像中构建代码
我不想node_modules
在最终图像中包含文件夹(太大)
所以我决定捆绑我的server.js
node_modules
捆绑后,我将在最终图像中删除。
但在我的server.js
const express = require('express')
const bundle = require('./dist/vue-ssr-server-bundle.json')
Run Code Online (Sandbox Code Playgroud)
它需要我的dist/
js ,我不想要 webpack 捆绑 dist/ 文件夹内容,node_modules
就像express
唯一捆绑node_modules
经过很长时间的等待
我收到了
Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Run Code Online (Sandbox Code Playgroud)
这是我的 webpack 配置
const path = require('path')
const resolve = (...dir) => path.resolve(...dir)
module.exports = {
entry: resolve(__dirname, '../server.js'),
output: {
filename: …
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
let p = new Proxy([1, 2, 3], {
get: function() {
console.log('get')
}
})
console.log(p)
Run Code Online (Sandbox Code Playgroud)
我觉得Proxy
应该代理一切有关[1,2,3]
。
当我log
取值时,它应该从 读取值[1,2,3]
,因此应该触发 getter。
但是当我在getter中设置断点时,断点没有命中?
为什么不console.log
和console.table
引发的getter函数?
当我使用jQuery时,我是打字稿的新手,
export class IDE{
init():any{
$("select").on("change",function(){
this.run();//cannot working because we in jQuery context.
})
}
run():any{
}
}
Run Code Online (Sandbox Code Playgroud)
这个关键字被jQuery'this'关键字覆盖,有人可以给我一些想法吗?