2 red931744496 red931744496 于 2016.05.11 16:51 提问

timeline.js生成时间轴问题
 <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Timeline</title>

    <!-- The default timeline stylesheet -->
    <link rel="stylesheet" href="assets/css/timeline.css"/>
    <!-- Our customizations to the theme -->
    <link rel="stylesheet" href="assets/css/styles.css"/>


</head>

<body>

<header>
    <h1 id="nodeName"></h1>
</header>

<div id="timeline">
    <!-- Timeline.js will genereate the markup here -->
</div>

<!-- JavaScript includes - jQuery, turn.js and our own script.js -->
<script src="assets/js/jquery-1.7.1.js"></script>
<script src="assets/js/timeline.js"></script>
<script>
    var obj = {
        "timeline": {
            "headline": "Events timeline",
            "type": "default",
            "startDate": "2015,4",
            "text": "<i><span class='c1'>事件</span> & <span class='c2'>时间轴</span></i>",
            "date": [
                {
                    "startDate": "2016,4,15",
                    "headline": "违法违规|债务违约",
                    "text": "<a href='http://business.sohu.com/20160415/n444244012.shtml' target='_blank'>交易商协会调查绿地控股信披违规 或与云峰违约有关</a>",
                    "asset": {
                        "media": "",
                        "credit":"<a href='http://business.sohu.com/20160415/n444244012.shtml' target='_blank'>违规|违约</a>",
                        "caption": ""
                    }
                },
                {
                    "startDate": "2016,4,9",
                    "headline": "违约",
                    "text": "<a href='http://finance.qq.com/a/20160409/017663.htm' target='_blank'>云峰债违约内幕:信披夸大净资产超十倍</a>",
                    "asset": {
                        "media": "assets/img/shots/sidebar_s3.jpg",
                        "credit": "",
                        "caption": ""
                    }
                }
            ]
        }
    };
    //****************
    (function () {
        var timeline = new VMM.Timeline();
        timeline.init(obj);
    })();
</script>

</body>
</html>
报错,请问如何解决?

2个回答

CSDNXIAOD
CSDNXIAOD   2016.05.11 17:02

针对时间轴TimeLine的一些js操作
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!

showbo
showbo   Ds   Rxr 2016.05.11 17:13

刚才测试了timeline.js好像是不支持数据源直接为json对象,将数据存为json文件(不包含var obj = 这个内容,注意utf-8存储编码),然后

timeline.init(obj);
改为
timeline.init("json文件路径");

就没有问题了

red931744496
red931744496 谢谢你。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!