我目前有一个巨大的JSON文件(超过15,000行,大小可能会增加),我想用它构建一个bootstrap-treeview。添加所有节点会使页面的加载真正变慢,因此我计划创建一个服务来获取所选节点的JSON并相应地填充treeview。这就是我现在所拥有的。
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Tree View</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="./TreeView_files/bootstrap-treeview.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Bootstrap Tree View - DOM Tree</h1>
<br/>
<div class="row">
<div class="col-sm-12">
<label for="treeview"></label>
<div id="treeview"/>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="./TreeView_files/bootstrap-treeview.js"></script>
<script type="text/javascript">
function buildDomTree() {
var tree = [
{
text: "Parent 1",
nodes: [
{
text: "Child 1",
nodes: [
{
text: "Grandchild 1"
},
{
text: "Grandchild 2"
}
]
},
{
text: "Child 2"
}
]
}, …Run Code Online (Sandbox Code Playgroud) 我目前正在使用查询 8 次Query<>(8 次是因为我必须将一些列转换为 JSON,有时是单独的)来生成所需的完整结果集。但是,我想知道是否可以通过使用QueryMultiple. 我有一个假设QueryMultiple可以同时查询所有这些表,因此我不必等待每个查询完成。
我还有另一种选择。它是*Async方法的使用版本。
QueryMutiple但是,如果不显着更改代码,我就无法实现。我应该使用常规方法QueryMutiple还是*Async常规方法的版本?两种替代方案之间的权衡是什么?我应该使用哪一种?
我已经声明了我的数据对象,queuedItemList: []它应该包含由后台服务提供的一组项目。在 HTTP 请求之后,我使用类似的 for 循环填充列表
for(var i = 0; i < getList.length; i++) {
var newObject = Object.assign({}, getList[i]);
this.queuedItemList.splice(i, 1, newObject);
}
Run Code Online (Sandbox Code Playgroud)
用于填充以下模板
<Item v-for="(item, index) in queuedItemList" :key="index" :componentData="item" :index="index" @remove="removeItem">
</Item>
Run Code Online (Sandbox Code Playgroud)
I am supposed to do a periodic HTTP GET to get the new list of items, which may also contain current items with maybe different state. Inside the component, I am using a v-if to select between two different icons.
<v-icon name="play" class="controlIcons" …Run Code Online (Sandbox Code Playgroud) 我正在尝试等待异步函数完成,以便我可以在我的UI线程中填充ListView.
这是代码
public Form1()
{
InitializeComponent();
Task t = new Task(Repopulate);
t.Start();
// some other work here
t.Wait(); //completes prematurely
}
async void Repopulate()
{
var query = ParseObject.GetQuery("Offer");
IEnumerable<ParseObject> results = await query.FindAsync();
if (TitleList == null)
TitleList = new List<string>();
foreach (ParseObject po in results)
TitleList.Add(po.Get<string>("title"));
}
Run Code Online (Sandbox Code Playgroud)
FormList()中的TitleList = null,因为尚未完成Repopulate().因此我使用了Wait().但是,等待在函数完成之前返回.
我在这做错了什么?
c# ×2
async-await ×1
dapper ×1
dynamic ×1
json ×1
treeview ×1
vue.js ×1
vuejs2 ×1
vuetify.js ×1