This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{-- 引用vue的主要檔案 --}} | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script> | |
<div id="app"> | |
<ul> | |
<li v-for="todo in todos"> | |
{{ todo.text }} | |
</li> | |
</ul> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-router/2.0.0-rc.3/vue-router.js"></script> | |
<div id="app"> | |
<h1>Hello App!</h1> | |
<ul> | |
<li> | |
<router-link to="/foo">foo</router-link> | |
</li> | |
<li> | |
<router-link to="/bar">bar</router-link> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.map({ | |
'/foo': { | |
component: Foo | |
}, | |
'/bar': { | |
component: Bar | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="parents"> | |
<h3>子組件內容:</h3> | |
<child :message="parentsMessage"></child> | |
</div> | |
<script> | |
//定義子組件 | |
Vue.component('child', { | |
props:['message'], | |
template: '<div>{{ message }}</div>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function currency(value){ | |
value += ""; | |
var arr = value.split("."); | |
var re = /(\d{1,3})(?=(\d{3})+$)/g; | |
return arr[0].replace(re, "$1,") + (arr.length == 2 ? "." + arr[1] : ""); | |
} | |
export {currency}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {currency} from '../filters.js'; | |
new Vue({ | |
methods:{ | |
//在 methods 中引入 currency 方法 | |
currency | |
} | |
}).$mount('#should-currency') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="should-currency"> | |
<p>{{ currency('10000000') }}</p> | |
</div> | |
<script src="{{ URL::asset('js/app.js') }}"></script> |