0
Hello, I’m trying to create a currency converter with a component, but I’m trying problems
index.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta charset="utf-8"/>
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue JS</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<conversor></conversor>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="index.js"></script>
</html>
index js.
Vue.component('conversor', {
props:{
moedaA:{
default:""
},
moedaB:{
default:""
},
},
template: ` <h2>{{moedaA}} Para {{moedaB}}</h2>
<input type="text" v-model="moedaA_value" v-bind:placeholder="moedaA">
<input type="button" value="Converter" v-on:click="converter">
<h2>{{moedaB_value}}</h2>`,
})
new Vue({
el: '#app',
data: {
},
})
Error:
Error compiling template:
Component template should contain Exactly one root element. If you are using v-if on Multiple Elements, use v-Else-if to chain them Instead.
Puts a
<div>
around everything that’s inside thetemplate:
. Solve your problem?– Sergio
I tried to do it but no solution :/
– Bruno Teles