Django and Vue grammar conflict problem perfect solution

When we django web framework, the use of vue, the syntax will encounter conflict.

since vue use {{}}, but also use django {{}}, and therefore conflict.

solution 1:

after django1.5, the added tag:

  {% verbatim myblock %} {% endverbatim myblock%}  

label wrapped by this code will not be rendered Django template engine.

Thus, we can Vue {} {} with the code on the {% verbatim myblock%} label intermediate, for example:

  
{% verbatim myblock%} {{message1}} {% endverbatim myblock%}

solution 2:

the modified Vue {} to {[]}

   Vue.config.delimiters = [ "{[", "]}"]   

when used:

  
{[message1]}

ps: vue vue syntax of django and conflict management

modified symbol vue.js default binding of

vue2.0 obsoleteThis way:

vue.config.delimiter = [‘[[[‘, ‘]];
   
Correct posture:

VAR VM = New Vue ({DELIMITERS: [‘[[[‘, ‘]]’], el: ‘# Box’, DATA: {Arr: [‘apple’, ‘pear’, ‘grape’]}, methods: {add: function () {this.arr.push (‘tomato’)}}}

   
The above is the perfect solution for the conflict problem of Django and Vue grammar introduced to you, I hope that everyone has helpful. If you have If you have any questions, please leave a message, the small package will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment