vscode中安装开发html5中需要的插件

最近在学习H5,也开始尝试着用vscode来写h5的代码。vscode是一个很不错的剪辑器,已经用它来写过php,python,还有vue的代码了。最近使用它写H5的代码,推荐一些H5有关的插件。

1.Emmet是一款编辑器插件,支持多种编辑器支持。在前端开发中Emmet使用缩写语法快速编写HTML、CSS以及实现其他的功能,极大的提高了前端开发效率。

(PS:我发现在vue中,tab不起作用,那么需要再settings.json中加入 ) 

"emmet.triggerExpansionOnTab": true,
"emmet.includeLanguages": {
    "vue-html": "html",
    "vue": "html"
}
 

a.安装完之后,创建一个html的文件敲入!,然后按一下tab就会出现h5的基本框架。

b.可以直接用缩写敲入div,按tab,就会出现<div></div>

c. .page会被转译成<div class="page"></div>

d. ul>li*5会被转译成

<ul>

        <li></li>

        <li></li>

        <li></li>

        <li></li>

        <li></li>

    </ul>

可以去查一下emmet的文档,这样可以加快自己的开发效率

2.格式化插件 vuter,eslint,setting中加入以下设置

  //autoFixedOnSave 设置已废弃,采用如下新的设置
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "eslint.format.enable": true,
  //autoFix默认开启,只需输入字符串数组即可
  "eslint.validate": [
    "javascript",
    "vue",
    "html"
  ],
  "editor.quickSuggestions": {
    //开启自动显示建议
    "other": true,
    "comments": true,
    "strings": true
  },
  // vscode默认启用了根据文件类型自动设置tabsize的选项
  "editor.detectIndentation": false,
  // 重新设定tabsize
  "editor.tabSize": 2,
  // #每次保存的时候自动格式化 
  "editor.formatOnSave": true,
  // #每次保存的时候将代码按eslint格式进行修复
  //  #让prettier使用eslint的代码格式进行校验 
  "prettier.eslintIntegration": true,
  //  #去掉代码结尾的分号 
  "prettier.semi": false,
  //  #使用带引号替代双引号 
  "prettier.singleQuote": true,
  //  #让函数(名)和后面的括号之间加个空格
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
  // #这个按用户自身习惯选择 
  "vetur.format.defaultFormatter.html": "js-beautify-html",
  // #让vue中的js按编辑器自带的ts格式进行格式化 
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "force-aligned"
      // #vue组件中html代码格式化样式
    }
  },
  // 格式化stylus, 需安装Manta's Stylus Supremacy插件
  "stylusSupremacy.insertColons": false, // 是否插入冒号
  "stylusSupremacy.insertSemicolons": false, // 是否插入分好
  "stylusSupremacy.insertBraces": false, // 是否插入大括号
  "stylusSupremacy.insertNewLineAroundImports": false, // import之后是否换行
  "stylusSupremacy.insertNewLineAroundBlocks": false,
  "[javascript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "window.zoomLevel": 0, // 两个选择器中是否换行
  /** Easy Sass 插件 **/
  "easysass.formats": [
    {
      "format": "expanded", // 没有缩进的、扩展的css代码
      "extension": ".css"
    }
  ],
  "easysass.targetDir": "./css/" // 自定义css输出文件路径

3.open in brower,安装之后就可以用游览器打开html文件

4. Live Server VSCode前端文件(html文件)以服务器模式打开

在局域网内可以设置成本地ip,然后让同一局域网内的手机或者其他设备打开。

 

先分享着4个,如果以后发现其他好用的插件再继续分享。

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
和相关的CSS和JavaScript文件? 在VS Code插件开发,可以通过webviewView提供的API来导入HTML文件和相关的CSS和JavaScript文件。首先,需要使用webviewView的createWebviewPanel方法创建一个webview面板。然后,可以通过webview的HTML内容来指定要加载的HTML页面,并且可以使用webview的样式和脚本列表来导入对应的CSS和JavaScript文件。具体的代码实现可以参考以下示例代码: ```typescript import * as vscode from 'vscode'; export function activate(context: vscode.ExtensionContext) { let disposable = vscode.commands.registerCommand('my.extension.showWebview', () => { const panel = vscode.window.createWebviewPanel( 'myWebview', 'My Webview', vscode.ViewColumn.One, { enableScripts: true, localResourceRoots: [vscode.Uri.file(context.extensionPath)] } ); // Load the webview HTML panel.webview.html = getWebviewContent(context); // Handle messages from the webview panel.webview.onDidReceiveMessage( message => { vscode.window.showInformationMessage(`Received message: ${message}`); }, undefined, context.subscriptions ); }); context.subscriptions.push(disposable); } function getWebviewContent(context: vscode.ExtensionContext) { const scriptUri = vscode.Uri.file(path.join(context.extensionPath, 'myscript.js')); const styleUri = vscode.Uri.file(path.join(context.extensionPath, 'mystyle.css')); const scriptPathOnDisk = scriptUri.with({ scheme: 'vscode-resource' }).toString(); const stylePathOnDisk = styleUri.with({ scheme: 'vscode-resource' }).toString(); return ` <html> <head> <link rel="stylesheet" type="text/css" href="${stylePathOnDisk}"> </head> <body> <h1>Hello Webview</h1> <script src="${scriptPathOnDisk}"></script> </body> </html> `; } ``` 在以上代码,首先使用createWebviewPanel方法创建了一个名为'myWebview'的webview面板。在调用createWebviewPanel时,需要传入一个enableScripts选项,表示是否允许webview执行JavaScript脚本。同时,还需要为webview指定一个localResourceRoots选项,表示webview可以加载的静态资源的根路径。 接着,通过getWebviewContent方法获取要加载的HTML内容。在getWebviewContent方法,使用了Uri.file方法获取了要导入的CSS和JavaScript文件的路径。然后,根据这些路径生成对应的resource URI,用于指定在webview加载这些文件。最后,在HTML内容通过link标签和script标签引入了CSS和JavaScript文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小猴子编程

请支持一下我的分享

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值