phoenix使用vue--单独js(不使用app.js)
实际中不能都在一个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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content=""> <title>Hello Ass2!</title>
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
</head> <body>
<div class="container">
<header class="header">
<nav role="navigation">
<ul class="nav nav-pills pull-right">
<li><a href="http://www.phoenixframework.org/docs">Get Started</a></li>
</ul>
</nav>
<span class="logo"></span>
</header> <p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p> <main role="main">
<%= render @view_module, @view_template, assigns %>
</main> </div> <!-- /container -->
<script src="<%= static_path(@conn, "/js/vendor.js") %>"></script>
<script src="<%= static_path(@conn, "/js/admin.js") %>"></script>
<script>
require('web/static/admin/hello');
</script>
</body>
</html>
index.html.eex
<div id="hello-world">
{{message}}
</div>
phoenix使用vue--单独js(不使用app.js)的更多相关文章
- 小程序公用js提取到app.js中调用的实例
index.wxml: <view "> <text>{{page}}</text> </view> <view "> ...
- 小程序-调用公共js对象方法/ app.js
在小程序中,如果在子页面想调用共公js的方法,需先在子页面js中先实例化app:具体过程如下 子页面js: 1 2 3 4 5 6 7 8 //调用公共js对象以便调用其方法 var app = ge ...
- 解决使用vue打包时vendor文件过大或者是app.js文件很大的问题
这篇文章主要介绍了使用vue打包时vendor文件过大或者是app.js文件很大问题的解决方法,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下 第一次使用vue2.0开发,之前都是用的angu ...
- App.js实现使用js开发app的应用,此文是中文文档
在阅读前,在此说明下,本人英文一直不好,所以该文档是借助翻译工具翻译的,阅读起来可能有点不好,请各位谅解,哪位大神有标准的中文文档请分享下 Github下载地址:https://github.com/ ...
- 微信小程序 --- 设置app.js/page.js参数的方法
设置 app.js 文件: //app.js App({ globalData: { is_login:false, userInfo:{} } }) 设置gloabalData的方法: // 定义a ...
- 通过const app = getApp()实现在 page 页面获取 app.js 定义的属性globalData,即获取全局数据
App.js是项目的入口文件,页面的 page.js 文件会覆盖 app.js文件, App.js文件里面的一些方法: onLaunch : function(){}:这个方法是当小程序加载完毕后就执 ...
- js模块化开发——require.js的用法详细介绍(含jsonp)
RequireJS的目标是鼓励代码的模块化,它使用了不同于传统<script>标签脚本加载步骤.可以用它回事.优化代码,但其主要的目的还是为了代码的模块化.它鼓励在使用脚本以moudle ...
- vue.js移动端app实战2:首页
貌似有部分人要求写的更详细,这里多写一点vuel-cli基础的配置 什么是vue-cli? 官方的解释是:A simple CLI for scaffolding Vue.js projects, 简 ...
- vue.js移动端app实战2
貌似有部分人要求写的更详细,这里多写一点vuel-cli基础的配置 什么是vue-cli? 官方的解释是:A simple CLI for scaffolding Vue.js projects,简单 ...
随机推荐
- 解决后台json数据返回的字段需要替换的问题
有时候后台json数据返回的字段含有“id”,也有可能是有时候为了减少代码的冗余,两页面之间只是数据模型个别属性的区别,所以这时候最好是用到模型属性的替换,用新的属性替换返回的json数据的字段.这里 ...
- vertical-tical
通常我们需要垂直对齐并排的元素. CSS提供了一些可实现的方法:有时我用浮动float来解决,有时用position: absolute来解决,有时甚至是“肮脏”地手动添加的margin或paddin ...
- shiro授权-记调试过程
根据张开涛老师的shiro教程学习过程中 感觉shiro授权这块有点绕 调试了十几遍 大概有个思路 记录一下 1.单元测试入口 2.subject().isPermitted("+user ...
- Android IntentFilter匹配规则
一:显式调用 需要明确指定被启动对象的组件信息,一般是在相同的应用程序内部实现的 Intent intent = new Intent(); intent.setClass(SecondActivi ...
- Java之集合(六)PriorityQueue
转载请注明源出处:http://www.cnblogs.com/lighten/p/7299233.html 1.前言 本章介绍队列中的PriorityQueue--优先队列,顾名思义,这是一个可以指 ...
- Impala配置HA-Nginx
Impala的高可用配置,官方的例子用的是Haproxy,考虑到nginx配置简单,使用人群广泛,再加上nginx1.9以后支持TCP的负载均衡,所以选用nginx. nginx安装:yum inst ...
- EF CodeFirst Mirgration
新建类库Models,加入以下三个类: Product: public class Product { /// <summary> /// 编号 /// </summary> ...
- safari input默认样式
在i标签下嵌套一个input标签 设置了 -webkit-apprarence:none: 设置了宽高,和padding:3px 结果placeholder显示不全 经排查 这时候的input默认有 ...
- C++的函数对象优于函数指针地方
转载自:http://blog.csdn.net/huang_xw/article/details/7934156 在C++编程语言中,有很多功能都与C语言相通,比如指针的应用等等.在这里我们介绍的则 ...
- js便签笔记(2)——DOM元素的特性(Attribute)和属性(Property)
1.介绍: 上篇js便签笔记http://www.cnblogs.com/wangfupeng1988/p/3626300.html最后提到了dom元素的Attribute和Property,本文简单 ...