简体   繁体   中英

How to run the html file created in Sublime Text in Chrome directly?

I tried creating a build system in sublime text and saving as chrome:

{
  "cmd":["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","$file"]
}

But it had no success. On running with ctrl B it shows No Build System

Note: I have selected Chrome in build system.

What I can do solve this?

The contents of a sublime-build file has to be valid JSON in order for Sublime to recognize it, but the build that you posted above is not valid.

The \\ character is special in JSON (as in many programming languages as well) in that it indicates that the next character should be interpreted specially, for example \\n meaning "start a new line".

In order to use a \\ character in a string, you need to double it to tell the JSON parser that it's just supposed to be a regular character and not special. For example:

{
  "cmd":["C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe","$file"]
}

Alternatively Windows generally accepts / in place of \\ in paths, which depending on your preference can be a little easier to look at visually:

{
  "cmd":["C:/Program Files (x86)/Google/Chrome/Application/chrome.exe","$file"]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM