代码之家  ›  专栏  ›  技术社区  ›  sicreep

Vue模板中的HTML语法高亮显示

  •  0
  • sicreep  · 技术社区  · 1 年前

    我在laracast.com上学习Vue3教程。我编写了以下按钮模板:

    export default {
      template: `
        <button 
          :class="{
            'border rounded px-5 py-2 disabled:cursor-not-allowed' : true,
            'bg-blue-600 hover:bg-blue-700' : type == 'primary',
            'bg-purple-200 hover:bg-purple-400' : type == 'secondary',
            'bg-gray-200 hover:bg-gray-400' : type == 'muted',
            'is-loading' : processing
          }" 
          :disabled="processing"
        >
          <slot />
        </button>
      `,
    
      props: {
        type: { // name of the prop
          type: String, // the real type of the prop..
          default: 'primary'
        },
        
        processing: {
          type: Boolean,
          default: false
        }
      },
    };
    

    不幸的是,VS Code没有对模板的HTML部分应用任何语法高亮显示:

    missing syntax highlighting

    我安装了以下扩展:

    • Vue官方扩展
    • Vue 3支持-一体化
    • Vue VSCode代码段
    • Vue扩展盒

    有没有办法在这类模板中突出显示语法?你是怎么处理的?

    这同样适用于空白HTML代码:

    missing syntax highlighting

    1 回复  |  直到 1 年前
        1
  •  2
  •   parapente    1 年前

    您可以尝试使用 "Vue Inline Template" VSCode的扩展。这似乎适用于你所举的例子。

    推荐文章