turn.js 圖書翻頁效果

來源:互聯網
上載者:User

標籤:

今天用turn.js 做圖書的翻頁效果遇到問題:

圖片路徑總是出錯

調了一天,總算調出來了

我用的thinkphp,其他的不知道是不是一樣

兩個地方要改動:

1.後台查出地址

注意的地方:1.地址要完全的

      2.js要用json格式的資料

 

$more = M(‘File‘)->where(array(‘id‘=>$id))->find();$more1 = json_decode($more[‘more‘],true);  foreach($more1 as $k => $v){  /*weburl 是網站網域名稱  savepath 是圖片存放地址*/ $v[‘path‘] = C(‘WEBURL‘).‘/‘.$v[‘savepath‘]; $type = end(explode(‘.‘,$v[‘name‘])); if(‘jpg‘ == $type){      $more2[] = $v;    } }$more[‘more2‘] = $more2;$more[‘more3‘] = json_encode($more2);$this->assign(‘more‘,$more);

2.前台js形成需要的json資料往方法傳

var more = <{$more.more3}>;    var savepath = new Array();    var i=1;    $.each(more, function(e,v){        savepath[i] = v.path;        i++;    });
missing: function (event, pages) {    // Add pages that aren‘t in the magazine    for (var i = 0; i < pages.length; i++){    addPage(pages[i], $(this),savepath);    }}

 

3.magazine.js要改動

 

function addPage(page, book,data) function loadPage(page, pageElement,data)有好幾個地方要改圖片路徑img.attr(‘src‘, data[page]);//img.attr(‘src‘, ‘pages/‘ +  page + ‘.jpg‘);

 

turn.js 圖書翻頁效果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.