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>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</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">
<div v-for='product in products | filterBy search in "name"' 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 class="col-sm-4">
<h1>shopping cart</h1>
<div class="row" v-for='product in shopping_cart'>
<div class="col-xs-12 col-sm-4">
{{product.quantity}} @ {{product.price | currency}}
</div>
<div class="col-xs-12 col-sm-5">
{{product.listitem}}
</div>
<div class="col-xs-12 col-sm-3 text-right">
<small>{{product | subvalue | currency}}</small>
</div>
</div>
</div>
</div>
</div>
<!-- <pre>{{$data | json}}</pre> -->
</div>
<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>
<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 incart=[
{
price:100,
listitem:'some product',
quantity:4,
id:1
},{
price:10,
listitem:'some other product',
quantity:2,
id:2
}
];
Vue.filter('subvalue',function(value){
return value.price * value.quantity;
});
var vm=new Vue({
el:'#app',
data:{
products:inventory,
shopping_cart:incart,
subtotal:0,
search:'',
order:1
}
});
Vue.config.devtools = true;
</script>
</body>
</html>
全站熱搜
留言列表