index4.html
<html>
<head>
<meta charset="UTF-8">
<script src="https://unpkg.com/vue"></script>
<link rel="stylesheet" href="index2.css">
</head>
<body>
<div id="app">
<div id="product">
<div class="product-image">
<img :src="image"/>
</div>
<div class="product-info">
<h1>{{ product }}</h1>
<p v-if="inStock">In Stock</p>
<p v-else>Out of Stock</p>
</div>
<ul>
<li v-for="detail in details">{{ detail }} </li>
</ul>
<div v-for="variant in variants" :key="variant.variantId" >
<p>{{ variant.variantColor }} </p>
</div>
</div>
</div>
<script src="index4.js"></script>
</body>
</html>
index4.js
var app = new Vue({
el: '#app',
data: {
product: 'Socks'
, image: "https://www.vuemastery.com/images/challenges/vmSocks-green-onWhite.jpg"
, inStock: true
, details : ["80% cotton" , "20% polyester", "Gender-neutral"]
, variants : [ { variantId : 2234, variantColor : "green"}
, { variantId : 2235, variantColor : "blue"}
]
}
});
실행 결과
'언어 > vue' 카테고리의 다른 글
vue Invalid Host header (0) | 2020.08.12 |
---|---|
[vue - 3] if - else 적용 (0) | 2020.08.04 |
[vue - 2] 이미지 속성 변경하기 (0) | 2020.08.04 |
[vue -1] Hello Vue! 표시하기 (0) | 2020.08.04 |