Skip to content
Advertisement

Vue bindings and CSS in HTML does not work

I am trying to display vue within an HTML. It worked properly with the vue cli but now that I am trying to integrate it in a bare HTML file, CSS doesn’t work properly anymore. It might as well has to do with the bindings of vue since the shown bar should repeat three time, but is only shown once. I don’t get any error in the console so I’m clueless. Any help is appreciated!

result of html atm

how it looked like with vue cli

JavaScript

Advertisement

Answer

Add id attribute with app as value in the root div then in vue instance set el:"#app" instead of name:"#app" and set key to index v-bind:key="index" finally replace v-bind:class="{ closed: this.switchObj[index]==='closed', opened: this.switchObj[index]==='opened' }" by v-bind:class="{ closed: str==='closed', opened: str==='opened' }"

JavaScript
Advertisement