Skip to content

Instantly share code, notes, and snippets.

View gist:c8cd4cd5dc67f808fd5369d234ae8d37
<div id="should-currency">
<p>{{ currency('10000000') }}</p>
</div>
<script src="{{ URL::asset('js/app.js') }}"></script>
View filters-vue
import {currency} from '../filters.js';
new Vue({
methods:{
//在 methods 中引入 currency 方法
currency
}
}).$mount('#should-currency')
View filters.js
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};
View props
<div id="parents">
<h3>子組件內容:</h3>
<child :message="parentsMessage"></child>
</div>
<script>
//定義子組件
Vue.component('child', {
props:['message'],
template: '<div>{{ message }}</div>'
View old-router-map
router.map({
'/foo': {
component: Foo
},
'/bar': {
component: Bar
}
})
View vue-router-test
<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>
View gist:3264b39c8deb63332ca44fd04a887332
{{-- 引用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>