$cache[$key] = empty($arr) ? NULL : $arr; return $cache[$key]; } // 门户 获取需要在频道显示的栏目主题数据 function portal_channel_thread($fid) { global $forumlist; if (empty($fid)) return NULL; $orderby = array('tid' => 1); $page = 1; // 遍历所有在频道显示内容的栏目 $category_forumlist = channel_category($fid); $arrlist = array(); $forum_tids = array(); $tidlist = array(); if ($category_forumlist) { foreach ($category_forumlist as &$_forum) { // 频道显示数据 $arrlist['list'][$_forum['fid']] = array( 'fid' => $_forum['fid'], 'name' => $_forum['name'], 'rank' => $_forum['rank'], 'type' => $_forum['type'], 'url' => $_forum['url'], 'channel_new' => $_forum['channel_new'], ); $forum_thread = thread_tid__find(array('fid' => $_forum['fid']), $orderby, $page, $_forum['channel_new'], 'tid', array('tid')); // 最新信息按栏目分组 foreach ($forum_thread as $key => $_thread) { $forum_tids[$key] = $_thread; } unset($forum_thread); } $tidlist += $forum_tids; } unset($category_forumlist); // 获取属性对应的tid集合 list($flaglist, $flagtids) = flag_thread_by_fid($fid); empty($flagtids) || $tidlist += $flagtids; unset($flagtids); // 频道置顶 $stickylist = sticky_list_thread($fid); empty($stickylist) || $tidlist += $stickylist; // 在这之前合并所有二维数组 tid值为键/array('tid值' => tid值) $tidarr = arrlist_values($tidlist, 'tid'); // 在这之前使用$tidarr = array_merge($tidarr, $arr)前合并所有一维数组 tid/array(1,2,3) if (empty($tidarr)) { $arrlist['list'] = isset($arrlist['list']) ? array_multisort_key($arrlist['list'], 'rank', FALSE, 'fid') : array(); return $arrlist; } $tidarr = array_unique($tidarr); $pagesize = count($tidarr); // 遍历获取的所有tid主题 $threadlist = well_thread_find_asc($tidarr, $pagesize); // 遍历时为升序,翻转为降序 $threadlist = array_reverse($threadlist); foreach ($threadlist as &$_thread) { // 各栏目最新内容 isset($forum_tids[$_thread['tid']]) AND $arrlist['list'][$_thread['fid']]['news'][$_thread['tid']] = $_thread; // 全站置顶内容 isset($stickylist[$_thread['tid']]) AND $arrlist['sticky'][$_thread['tid']] = $_thread; // 首页属性主题 if (!empty($flaglist)) { foreach ($flaglist as $key => $val) { if (isset($val['tids']) && in_array($_thread['tid'], $val['tids'])) { $arrlist['flaglist'][$key][array_search($_thread['tid'], $val['tids'])] = $_thread; ksort($arrlist['flaglist'][$key]); $arrlist['flag'][$_thread['tid']] = $_thread; } } } } unset($threadlist); if (isset($arrlist['sticky'])) { $i = 0; foreach ($arrlist['sticky'] as &$val) { ++$i; $val['i'] = $i; } } if (isset($arrlist['flag'])) { $i = 0; foreach ($arrlist['flag'] as &$val) { ++$i; $val['i'] = $i; } } if (isset($arrlist['flaglist'])) { foreach ($arrlist['flaglist'] as &$val) { $i = 0; foreach ($val as &$v) { ++$i; $v['i'] = $i; } } } isset($arrlist['list']) AND $arrlist['list'] = array_multisort_key($arrlist['list'], 'rank', FALSE, 'fid'); return $arrlist; } ?>javascript - How to host popper.js locally - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to host popper.js locally - Stack Overflow

programmeradmin0浏览0评论

I just upgraded to Bootstrap four and realized Popper.js was a dependency. I like to host libraries locally, as I sometimes need to work offline, but when I try to use it offline, I get an error unexpected token export. It works, however, when I use the Cloudflare CDN version, but how can I host popper.js locally?

(I don't want to use a package manager for this.)

I just upgraded to Bootstrap four and realized Popper.js was a dependency. I like to host libraries locally, as I sometimes need to work offline, but when I try to use it offline, I get an error unexpected token export. It works, however, when I use the Cloudflare CDN version, but how can I host popper.js locally?

(I don't want to use a package manager for this.)

Share Improve this question edited Mar 1, 2021 at 18:22 jeffkmeng asked Sep 20, 2017 at 3:57 jeffkmengjeffkmeng 8791 gold badge9 silver badges31 bronze badges 2
  • Can you post the code segment where you are calling popper initialization in your code? – Sahan Serasinghe Commented Sep 20, 2017 at 4:04
  • How did you download it? Package manager? – user47589 Commented Sep 20, 2017 at 4:04
Add a comment  | 

7 Answers 7

Reset to default 7

The README.md of the project will help sort this out:

Dist targets

Popper.js is currently shipped with 3 targets in mind: UMD, ESM and ESNext.

  • UMD - Universal Module Definition: AMD, RequireJS and globals;
  • ESM - ES Modules: For webpack/Rollup or browser supporting the spec;
  • ESNext: Available in dist/, can be used with webpack and babel-preset-env;

Make sure to use the right one for your needs. If you want to import it with a <script> tag, use UMD.

Hence, if you want to use Popper.js with a <script /> tag, you want to use the umd version of it. Located in dist/umd.

you can use bootstrap.bundle.min.js which already contain Popper.js

I also tried downloading popper and I tried to recreate your problem, and you are correct.

If you check the Quick Start section of getbootstrap.com page, you can find the following line in their example:

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>

Note the umd part in their link. You can download that file and add it locally and it will work.

PS - You may also have to change your jQuery import.

Download the official bootstrap files by clicking the first link on this page:

https://getbootstrap.com/docs/4.5/getting-started/download/

You can then use the bootstrap.bundle.min.css file in css which contains popper.js as well as the bootstrap code you might need

you can use it by using this code in your <head> tag:

<link rel="stylesheet" type="text/css" href="path-to/bootstrap-4.5.0/css/bootstrap.bundle.min.css">

I included 4.5.0 because that is the current version of bootstrap out there today

If you download Popper.js though

npm install popper.js

I found there are difference between npm package and its original source which is here https://popper.js.org/.

I just download popper.js from its original source and put it new js file. It worked for me.

Just download the source code and refer to it

Get the source code from the github page, then refer to it in your html

<script type="text/javascript" src="/path/to/downloaded/popper.js-1.12.5/dist/poppper.js" />

go to : https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js the right click and "save as..."

you can do the same with :

https://cdnjs.cloudflare.com/ajax/libs/popper.js/[popper-version]/umd/popper.js

and then in your code you add this line at the bottom between Jquery's and Bootstrap's .js link (script) :

发布评论

评论列表(0)

  1. 暂无评论