微楼书项目总结(一)前端

  • IFRAME

动态生成IFRAME

        // 新建IFRAME并设置模板链接
        var newIframeObject = document.createElement("IFRAME");
        newIframeObject.src = "panorama.html";
        // 设置显示宽高
        newIframeObject.width = "500px";
        newIframeObject.height = "500px";
        // 将IFRAME插入指定html
        $('.hxzs_imgshow').empty().append(newIframeObject);
        // IFRAME加载完成后执行
        newIframeObject.onload = function () {
            newIframeObject.contentWindow.update("view//img//houseType1//panorama1.PNG");
        }

IFRAME父级子级联动

父子级联动参考文章

示例

子级<script>标签内嵌方法

        function update(string) {
            xxxxxxxxxxxxxxxxxxxxx
        }

父级调用IFRAME内方法(利用onload方法确认IFRAME完全加载后执行方法)

        // 新建IFRAME并设置模板链接
        var newIframeObject = document.createElement("IFRAME");
        newIframeObject.src = "panorama.html";
        // 设置显示宽高
        newIframeObject.width = "500px";
        newIframeObject.height = "500px";
        // 将IFRAME插入指定html
        $('.hxzs_imgshow').empty().append(newIframeObject);

        // IFRAME加载完成后执行
        newIframeObject.onload = function () {
            // 执行IFRAME内方法
            newIframeObject.contentWindow.update("view//img//houseType1//panorama1.PNG");
        }
  • arttemplate

官网文档

示例

此处在html中预留一个<div id = "content">作为生成的模板放置的容器,再预留一个<script id="test">作为模板。

渲染模板先用template('test',data)语句找到模板'test',并将数据data填充进模板'test',然后根据容器id获取到容器,将生成的模板放置进容器里即可。

arttemplate不能直接迭代数组,如果填充的数据是淡出的数组形式data = [x,x,x,x],则需要在将数组转化为对象才能进行迭代,如{data},以下面的模板为例可以直接将list改成data便可进行迭代。

猜你喜欢

转载自blog.csdn.net/oneKnow/article/details/94633551