When using a component i got two errors
1-
[Vue warn]: Property or method "premium" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property
2-
[Vue warn]: Invalid prop: type check failed for prop "premium". Expected Boolean, got Undefined
Here is my Code:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>eCommerce</title>
</head>
<body>
<div id="app">
<product :premium='premium'></product>
</div>
<script src="public/plugins/bootstrap-4.3.1/js/bootstrap.min.js">
<script src="public/js/vue.js"></script>
<script src="public/js/app.js"></script>
</body>
</html>
app.js
Vue.component('product', {
props: {
premium: {
type: Boolean,
required: true
}
},
template: `
<div class="container">
<p>{{ premium }}</p>
</div>
`,
data() {
return {
cart: 0,
color: "white"
}
},
methods: {
addToCart() {
return this.cart++
},
}
}) //component
var app = new Vue({
el: '#app',
});