[Vuejs]-How to use php variable in Vue.js template literal?

0👍

Vue’s string interpolation (i.e., {{ topt }}) interprets the string as plain text, so the rendering will display the raw HTML.

Since you don’t actually need the HTML as a data variable, you could just insert the PHP variable directly into the component’s template option:

Vue.component('add-edit-card', {
  template: `<select id="component-type" class="form-control">
               <option>Select</option>
               {!! $types !!} 👈
             </select>`
});

Leave a comment