Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set custom delimiters in Vue.js 3

I am trying to set custom delimiters in Vue.js 3 but it does not seem to work.

The first thing I tried is setting the component parameter delimiters like this:

export default defineComponent({
    delimiters: ["${", "}$"],
    // ...
})

but nothing happens.

Then I tried setting main.ts file like this:

import { createApp } from "vue";
import router from "./router";
import App from "./App.vue";

App.delimiters = ["${", "}$"];

createApp(App)
   .use(router)
   .mount("#app");

Again the string interpolation in the template isn't working.

What am I missing?

like image 603
mastodilu Avatar asked Sep 17 '25 14:09

mastodilu


1 Answers

Needs to be inside the createApp

Example:

var app = Vue.createApp({
  data() {return {message: 'Ciao'}},
  // for global
  delimiters: ["${", "}$"],
  // for standalone
  compilerOptions: {
    delimiters: ["${", "}$"]
  }
}).mount('#app');
<script src="https://unpkg.com/[email protected]/dist/vue.global.prod.js"></script>
<div id="app"><h1>Message: ${message}$</h1></div>
like image 52
Daniel Avatar answered Sep 20 '25 05:09

Daniel