How to make a app using sails js + a vue js template?

会有一股神秘感。 提交于 2019-12-06 05:56:32

Right on the point:

  1. Put the .js files in your assets/js folder and your .css in assets/css.
  2. By default Sails inject in your layout.ejs all source files - styles and scripts - inside /assets, take a look bellow for more information. Disable that behavior on config/pipeline.js! Now you have 2 choices, use a layout (if you want to serve your .js file for all views) or simply put it in the end of your new view like this (remember to save it in the views/ folder with .ejs and only a body tag inside)`:

 <body>
  <div class="container" id="idforvue">
    Hello!
  </div>
  <!-- vuejs cdn here  -->
  <!-- your js href like '/js/myjs.js'  -->
</body>
  1. Setup a route for your view! Edit your config/routes.js and insert a new line '/' : { view: 'filename'},.

  2. Do a sails lift and access `localhost:1337' to see your changes.

More infos: First of all, you can use a lot of server-side rendering to solve some problems. Out of the box Sails uses EJS. Take a look here. Now you also want to read the Assets docs here. Dont underestimate this framework, it is awesome! Read the docs carefully and you should be fine...

EDIT: github example here: LINK

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!