vue-cli-plugin-pug icon indicating copy to clipboard operation
vue-cli-plugin-pug copied to clipboard

plugin doesn't work in Vue CLI v4.2.2

Open Dhruuva opened this issue 5 years ago • 5 comments

Hi ! I have create vue create my-vue

I just try that step in your manual: Either add the plugin from the vue ui interface, or run the following in your Vue-cli 3 project: vue add pug

After I update template in app.vue to pug template #app img(alt='Vue logo', src='./assets/logo.png') helloworld(msg='Welcome to Your Vue.js App')

And in browser i see this error vue-cli-plugin-pug

Failed to mount component: template or render function not defined.

Could You please fix it ? Best Regards.

Dhruuva avatar Feb 10 '20 10:02 Dhruuva

you may update vue-cli to V4.5.9,then it works.

Ge-yuan-jun avatar Dec 01 '20 13:12 Ge-yuan-jun

But maybe I find an error ?

I can run correctly

<template lang="pug">
img(alt="Vue logo", src="./assets/logo.png")
HelloWorld(msg="Welcome to Your Vue.js + TypeScript App")
</template>

But,when I change my indent like this:

<template lang="pug">
  img(alt="Vue logo", src="./assets/logo.png")
  HelloWorld(msg="Welcome to Your Vue.js + TypeScript App")
</template>

I find that the first line must be 0 indent.

should I change some config?

Ge-yuan-jun avatar Dec 01 '20 13:12 Ge-yuan-jun

Hi @Dhruuva and @Ge-yuan-jun. Vue components can only have 1 root element. So to render your example you would have to do this:

<template lang="pug">
  div
    img(alt="Vue logo", src="./assets/logo.png")
    HelloWorld(msg="Welcome to Your Vue.js + TypeScript App")
</template>

michaelalhilly avatar Dec 17 '20 18:12 michaelalhilly

@michaelalhilly Hello, the demo I provided uses vue 3.0, so, it can render more than 1 root element

Ge-yuan-jun avatar Feb 05 '21 09:02 Ge-yuan-jun

@Ge-yuan-jun My fault. Yes Vue 3 can have multiple root elements.

michaelalhilly avatar Feb 05 '21 19:02 michaelalhilly