为什么无法运行!DOCTYPE htmlhtml lang=enhead meta charset=UTF-8 meta http-equiv=X-UA-Compatible content=IE=edge meta name=viewport content=width=device-width initial-scale=10 titleDocumenttitle
这段代码无法运行是因为它缺少了一个 Vue 实例。需要在 标签外面添加一个 Vue 实例,例如:
<!DOCTYPE html>
<html lang="en">
<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">
<title>Document</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<template>
<nav>
<ul class="mainmenu" :class="current">
<router-link to="/fukuang"><li>待付款</li></router-link>
<router-link to="/fahuo"><li>待发货</li></router-link>
<router-link to="/shouhuo"><li>待收货</li></router-link>
</ul>
</nav>
<router-view/>
</template>
</div>
<style>
.mainmenu {
padding: 0;
margin: 0;
overflow: hidden;
width: 204px;
border: 1px solid #000;
}
.mainmenu li {
background-color: #FFA500;
display: inline-block;
padding: 4px 10px;
}
.mainmenu li:hover {
background-color: yellowgreen;
color: #fff;
font-weight: bold;
}
</style>
<script>
new Vue({
el: '#app'
});
</script>
</body>
</html>
这样就可以正确地运行了。
原文地址: http://www.cveoy.top/t/topic/bQPv 著作权归作者所有。请勿转载和采集!