我想从本地JSON
数据库获取元素,我有以下代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="./node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="col-md-12" id="app2">
{{ database }}
</div>
<script>
function httpGet(theUrl){
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false ); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="./node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="./node_modules/vue/dist/vue.min.js"></script>
<script>
var app2 = new Vue({
el: '#app2',
data: {
database: httpGet("http://a6b4a4a271.testurl.ws/metadata/")
}
})
</script>
</body>
</html>
所以现在我需要在变量“database”中显示数据库中的信息,而不是显示整个数据库。