当我尝试一个测试示例时,Vue 响应良好,但是当我大量使用下面的代码时,它不再起作用了,变化也不存在。有什么解决办法吗?
<!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">
<!--CDN Vuejs-->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Conversor</title>
<div id="app" class="container">
<h3>{{conversor()}}</h3>
<input type="text" class="form-group" v-model="num">
</div>
</head>
<body>
<script>
const app = new Vue({
el: '#app',
data: {
num: 100,
nDecimal: [1, 5, 10, 50, 100, 500, 1000],
nRomanos: ['I', 'V', 'X', 'L', 'C', 'D', 'M']
},
methods: {
conversor: function () {
if (this.nDecimal.indexOf(this.num) != -1) {
return this.nRomanos[this.nDecimal.indexOf(this.num)]
} else {
return 'Other'
}
}
}
});
</script>
</body>
</html>