求改写JS, 能在控制台直接赋值json到items这个变量

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>My App123</title>
<link rel="stylesheet" href="https://framework7.io/packages/core/css/framework7.bundle.min.css">

</head>
<body>

<div class="page-content">

<div class="list virtual-list media-list searchbar-found"></div>
</div>

<script type="text/javascript" src="https://framework7.io/packages/core/js/framework7.bundle.min.js"></script>

</script><script>
var app = new Framework7();

// Dummy items array
var items = [];
for (var i = 1; i <= items.rows; i++) {
items.push({
title: 'Item ' + i,
subtitle: 'Subtitle ' + i
});
}

var virtualList = app.virtualList.create({
// List Element
el: '.virtual-list',
// Pass array with items
items: items,
// List item Template7 template
itemTemplate:
'<li>' +
'<a href="#" class="item-link item-content">' +
'<div class="item-inner">' +
'<div class="item-title-row">' +
'<div class="item-title">{{title}}</div>' +
'</div>' +
'<div class="item-subtitle">{{subtitle}}</div>' +
'</div>' +
'</a>' +
'</li>',
// Item height
height: app.theme === 'ios' ? 63 : (app.theme === 'md' ? 73 : 46),
});</script>

</body>
</html>
=================
Framework7 的虚拟列表..., 想浏览器控制台本地测试换数据来着...
想要在控制台赋值这个items
var items = [];

var jsonVal = '{"id","111","name":"小杜"}';
这样就构造了一个包含json格式的js变量,后续如果解析;需要转化为json对象
比如:var jObject=jQuery.parseJSON(jsonVal );
alert("id="+jObject.id);
这个值就是预期的"111"了
温馨提示:内容为网友见解,仅供参考
无其他回答

Warning: Invalid argument supplied for foreach() in /www/wwwroot/www.t2y.org3v3b34/skin/templets/default/contents.html on line 47
相似回答