我正在尝试开发一个内部使用add i,但我有很多困难,甚至console.log
的事情。我之前问过一个问题。
我使用了yo office
工具中的generator-office
命令,使用react和excel作为选项。在here之后,我可以在本地服务并侧加载外接程序。之后,我在代码中添加了console.log(props)
,使其有点插入,但是找不到任何地方的输出(Chrome控制台、边缘控制台、PuthBeor或Excel本身)。我遵循了如何将VisualStudio调试器附加到进程中的指令,但这根本不起作用(在我之前的问题中描述过)。然后我转到了visual studio代码,希望微软自己的工具能够调试由另一个微软工具生成的项目。不过,情况似乎并非如此。
起初,调试器根本不运行,说它找不到要运行的程序。我四处搜索,找到了tutorial关于如何更改launch.json
和tsconfig.json
的typescript项目。之后,launch.json中的错误更改为“property outfiles is not allowed”,vscode控制台中的错误更改为:
NoDEYMease/@微软/Office JS助手/ DIST/Office助手。
-错误TS1319:默认导出只能在ECMAscript样式模块中使用。
628导出默认函数stringify(值:any):string;
下面是一些代码:launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/src/index.tsx",
"preLaunchTask": "tsc: build - tsconfig.json",
"outfiles": [
"${workspaceFolder}/out/**/*.js"
]
}
]
}
tsconfig.json
:{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"jsx": "react",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"outDir": "out",
"allowUnusedLabels": false,
"noImplicitReturns": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"lib": [
"es7",
"dom"
],
"pretty": true,
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"buildOnSave": false
}
我在10号窗口。
这真的让我对这个插件的开发有所退步,所以如果有人对如何进行调试或只是显示
console.log
的内容有任何建议,我将非常感激。 最佳答案
您能否尝试在chrome中运行应用程序并执行以下步骤:
右键单击项目页面并单击Inspect
转到Console
选项卡。
在右角,您将看到Settings
图标。点击它。
从选项中选中Preserve Log
并刷新页面。
你应该能看到日志。
注意:如果在WDS
生成的列表中找不到它,可以使用filter
功能查找日志。
使用console.log('props content', props);
并在props content
字段中键入console -> filter
。
关于reactjs - 如何调试React插件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55162493/