javascript 无法在 Chrome 开发工具的“源”选项卡中编辑 HTML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26473420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't edit HTML in Chrome dev tools Sources tab
提问by davidpm4
I have a noob question about the Sources panel in dev tools: when in the Elements tab I see my CSS to the right. I click on a CSS file and am brought to the Sources tab where I can make live edits. I can bring up the JS and do the same, but... If I bring up the HTML file, I am unable to make any edits to the HTML. Why is this? Is this by design? What am I missing?
我有一个关于开发工具中的 Sources 面板的菜鸟问题:当在 Elements 选项卡中时,我会在右侧看到我的 CSS。我单击一个 CSS 文件并进入“源”选项卡,在那里我可以进行实时编辑。我可以调出 JS 并执行相同的操作,但是...如果我调出 HTML 文件,则无法对 HTML 进行任何编辑。为什么是这样?这是故意的吗?我错过了什么?
回答by Barmar
Once the DOM is loaded, the browser doesn't use the original source, since the DOM can be modified on the fly by Javascript. If you want to make live edits to the DOM, you can do it in the Elements tab. Right click on an element or attribute, and there are options to edit it.
加载 DOM 后,浏览器不会使用原始源,因为 DOM 可以通过 Javascript 动态修改。如果要对 DOM 进行实时编辑,可以在 Elements 选项卡中进行。右键单击元素或属性,可以选择对其进行编辑。
回答by VanArman
If I understood you correctly, you are trying to edit the left side of source. Try to double click on position when you want to edit code or get right click mouse and click on "Edit as HTML".
如果我理解正确,您正在尝试编辑源代码的左侧。当您想要编辑代码或右键单击鼠标并单击“编辑为 HTML”时,请尝试双击位置。
回答by Hyman Elfrink
I had the same issue and a search got me to here.
我遇到了同样的问题,搜索使我来到这里。
For me what fixed it was to open the navagator bar, then click "filesystem", then click "add folder to workspace" , then click the folder location of whatever file you are wanting to edit. Once done, I was able to edit the html freely.
对我来说,修复的是打开导航栏,然后单击“文件系统”,然后单击“将文件夹添加到工作区”,然后单击要编辑的任何文件的文件夹位置。完成后,我就可以自由编辑 html。