javascript - 这个js要怎么使用?
習慣沉默
習慣沉默 2017-05-19 10:47:33
[JavaScript讨论组]
KISSY.add("mui/detail-review/mallphotos", function(e, t, a, r, i, s) {
    var n = ".",
        l = "",
        o = e.all,
        c, d = false;
    var u = {};
    var v = {};
    e.mix(v, {
        init: function(a, i) {
            c = this;
            c.el = t.get(a);
            if (!e.isArray(i)) return;
            var s = new r(f()).render(p(i));
            c.el.innerHTML = s;
            h()
        },
        run: function(e, r) {
            c = this;
            h(t.get(e));
            a.fire(r, "click")
        }
    });

    function f() {
        return '

    {{#each pics}}
  • {{/each}}

' } function p(e) { return { pics: e } } function h(r) { c.viewer = t.get(".tm-m-photo-viewer", r); var i = t.query("li", r); e.each(i, function(s, n) { a.on(s, "click", function(a) { e.log(t.attr(this.l, "src")); var r = t.css(this.v, "display"); var s = !t.equals(t.get(this.l), t.get(".tm-current", this.e)); if (r === "none" || s) { r = g(t.attr(this.l, "src"), this.v); t.removeClass(i, "tm-current"); t.addClass(this.l, "tm-current") } else { r = m(this.v, i) } }, { v: c.viewer, l: s, e: r }) }); a.on(c.viewer, "click", function(e) { if (e.target.tagName.toUpperCase() != "I" && e.target.tagName.toUpperCase() != "A") { m(this.v, i) } }, { v: c.viewer }); if (e.UA.ie && parseInt(e.UA.ie) < 8 || o(c.viewer).prev().children().length < 2) { o(c.viewer).all("a").remove() } else { var s = t.query("a", c.viewer); a.on(s, "click", function(e) { var a = t.query(this), r = t.parent(a); y(r, a) }); a.on(s, "mouseenter", function(e) { var t = o(this), a = t.parent().prev(), r = a.one(".tm-current").index(), i = t.index(); if (i == 1 && r == 0 || i > 1 && r == a.children().length - 1) { t.css("cursor", "default").one("i").hide() } else { if (d) { var s = t.height() / 2 - 10; t.css("cursor", "pointer").one("i").css("top", s).show() } } }); a.on(s, "mouseleave", function(e) { o(this).one("i").hide() }) } } function g(e, a) { s.gm("8.2.7"); var r = 410, n = 410; var l = function() { t.attr(t.get("img", a), "src", e); t.css(a, { display: "block", width: 400, height: 400 }); t.css(t.get("img", a), { width: 400 }) }; s.loadImage(e, function(s) { if (s.width > n || s.height > r) { l(); d = true } else { t.attr(t.get("img", a), "src", e); new i(a, { display: "block", width: s.width + 2, height: s.height + 2 }, .25, "linear", function() { d = true; var e = o(a).all("a"); e.css("width", o(a).width() / 3) }).run(); new i(t.get("img", a), { width: s.width + 2, height: s.height + 2 }, .25, "linear", function() {}).run() } }, function(e) { l() }); return true } function m(e, a) { new i(e, { display: "none", width: 0, height: 0 }, .5, "linear", function() { d = false }).run(); t.removeClass(a, "tm-current"); return false } function y(e, a) { var e = o(e), a = o(a), r = e.prev(), n = r.one(".tm-current"), l = a.index(), c = l == 2 ? n.next() : n.prev(); if (c) { var d = c.index(), u = c.attr("src"); n.removeClass("tm-current"); c.addClass("tm-current"); s.loadImage(u, function(s) { e.one("img").attr("src", u); new i(e, { display: "block", width: s.width + 2, height: s.height + 2 }, .25, "linear", function() { a.css("width", e.width() / 3) }).run(); if (l == 1 && d == 0 || l == 2 && d == r.children().length - 1) { a.css("cursor", "default").one("i").hide() } else { var n = (s.height + 6) / 2 - 10; a.show(); new i(a.css("cursor", "pointer").one("i"), { top: n }, .2, "linear", function() {}).run() } new i(t.get("img", e), { width: s.width + 2, height: s.height + 2 }, .25, "linear", function() {}).run() }) } } return v }

我想在htm文件里面使用这个图片点击放大的js,然后要直接在htm里面用这个代码

    {{#each pics}}
  • {{/each}}

这个要怎么配合使用,在htm直接使用上面代码,然后调用这个js

習慣沉默
習慣沉默

全部回复(1)
淡淡烟草味

上面不是写着KISSY框架吗,所以要使用的话:

  1. 引入kissy,这一步你可以下载对应的文件或者直接使用cdn//g.alicdn.com/kissy/k/1.4.8/seed-min.js

  2. 在页面文件中<script>引入你提到的js内容,或者用外联一个js文件也可以

  3. 在html页面文件,使用相应的格式的代码,一般框架都对应了一些特定形式的class或者其他属性,比如bootstrap用的data-

大体流程如上,具体KISSY的使用方式看KISSY的文档KISSY

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号