首页 > 解决方案 > "Mustache" syntax alternative for Vue template when using Pug language

问题描述

"Mustache" syntax allows defining data like this:

<template>
    <Window>
        <template v-slot:title >
            {{title}}
        </template>
    </Window>
</template>

but compilation with lang='pug' fails:

<template lang='pug'>
    <Window>
        <template v-slot:title >
            {{title}}
        </template>
    </Window>
</template>

With this error:

Module build fails: unexpected text "{{" ...

Other templates without mustache syntax usage build fine with lang='pug'. What's the Pug's alternative to mustache syntax?

标签: vue.jsvuejs2pugnuxt.js

解决方案


Note that the contents of your Pug template isn't actually Pug syntax, but that aside:

In Pug, plaintext should be inside a tag (e.g., span) or prefixed with the pipe character:

<template lang="pug">
Window
  template(v-slot:title="")
    | {{title}}
</template>

demo


推荐阅读