I
I
Ilya Vegner2018-06-15 14:33:08
JavaScript
Ilya Vegner, 2018-06-15 14:33:08

How to interact VueJS with ejs templating engine?

Hello everyone, I am writing a Node.js web application using express.js for training . I
took ejs as a template engine.
I decided to add interactive for the site and connected it to the page via CDN Vue and wrote a start element for Vue
. For the sake of interest, I tried to display a message, but ejs gives out error that message is not defined

<div id="contacts">
        <%= message %>
        <div class="addContact" v-for="">
          <label for="NameContact">
          Контакт:
            <input type="text" name="NameContact" placeholder="Например Вконтакте">
          </label>

          <label for="LinkContact">
          Контакт:
            <input type="text" name="LinkContact" placeholder="ссылка">
          </label>
        </div>
      </div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>

<script>
  
  var sample = new Vue({
    el: '#contacts',
    data: {
      defaultValue: {
        dafaultRow: 1
      },
      message: 'Helllo'
    }
  })

</script>

5b23a3cbd291d053327286.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan, 2018-06-15
@LiguidCool

I think if you poke the dock, you can find something about escaping characters, etc. ...
But in general, it would be correct to use one template engine. You, to some extent, are trying to put 2 antiviruses on one computer. If you really want to, then install a full-fledged Vue
file collector and keep the template in it. Then you make a bundle.

J
Jumandjilos, 2018-06-15
@Jumandjilos

https://ru.vuejs.org/v2/guide/single-file-componen... Read here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question