实际中不能都在一个js里
api.js
app.js
admin.js --vue 后台
记录下方法
static--admin--hello.js
import "phoenix_html"import Vue from "vue";new Vue({ el: "#hello-world", data: { message: "Hello World" }});
brunch-config.coffee
exports.config = files: javascripts: joinTo: 'js/vendor.js': /(^node_modules\/phoenix|^node_modules\/phoenix_html|^node_modules\/vue)/ 'js/app.js': /(^web\/static\/app)/ 'js/admin.js': /(^web\/static\/admin)/ stylesheets: joinTo: 'css/app.css' templates: joinTo: 'js/app.js' conventions: assets: /^(web\/static\/assets)/ paths: watched: [ 'web/static' 'test/static' ] public: 'priv/static' plugins: babel: ignore: [ /web\/static\/vendor/ ] modules: autoRequire: 'js/app.js': [ 'web/static/app/app' ] npm: enabled: true whitelist: [ 'phoenix' 'phoenix_html' 'vue' ]
app.html.eex
Hello Ass2! "><%= get_flash(@conn, :info) %>
<%= get_flash(@conn, :error) %>
<%= render @view_module, @view_template, assigns %>
index.html.eex
{ {message}}