close
<!DOCTYPE html>
<html lang="">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
		<title>Title Page</title>
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
		<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script>
	</head>
	<body>
		<div id="app">
			<div class="container">
				<div class="row">
					<div class="col-sm-8">
						<h1>products</h1>
						<input type="text" v-model="search">
						<button v-on:click='sortit("name")'>name</button>
						<div v-for='product in products | filterBy search in "name" | orderBy para order' class="col-md-12">{{product.name | capitalize}}
							<ul>
								<li v-for='opts in product.options'>{{opts.details}}{{opts.price | currency}}</li>
							</ul>
						</div>

					</div> 
				</div>
			</div>
		</div>
			<script type="text/javascript">
				var inventory=[
					{
						name:'Usb stick',
						options:[{
							id:1,
							details:'16GB',
							price:6.95
						},{
							id:2,
							details:'32GB',
							price:12.95
						},{
							id:3,
							details:'64GB',
							price:25.95
						}]
					},{
						name:'Usb plug',
						options:[{
							id:4,
							details:'3ft cable',
							price:4.35
						}]
					},{
						name:'small phone',
						options:[{
							id:5,
							details:'nokia phone',
							price:4.35
						}]
					},{
						name:'camera',
						options:[{
							id:6,
							details:'blue camaera',
							price:76.50
						},{
							id:7,
							details:'red camaera',
							price:76.50
						},{
							id:8,
							details:'yellow camaera',
							price:76.50
						},{
							id:9,
							details:'purple camaera',
							price:76.50
						}]
					}
				];
				var vm=new Vue({
					el:'#app',
					data:{
						products:inventory,
						subtotal:0,
						search:'',
						order:1,
						para:''
					},
					methods:{
						sortit:function(i){
							this.order=this.order*-1;
							this.para=i;
						}
					}
				});
				Vue.config.devtools = true;
			</script>
		<script src="https://code.jquery.com/jquery.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
	</body>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Jerry 的頭像
    Jerry

    Bug倉庫 // 程式日記

    Jerry 發表在 痞客邦 留言(0) 人氣()