簡體   English   中英

在ionic3中使用jQuery dotdotdot

[英]Using jquery dotdotdot in ionic3

我正在嘗試在項目中使用jQuery插件。 我正在使用Ionic3

我已經安裝了jquery,還下載了插件

npm install jquery --save typings install dt~jquery --global --save

來自插件文檔:我在index.html添加了腳本標簽

<head>
 ////
 <script src="assets/jquery/dist/jquery.js" type="text/javascript"></script>
 <script src="assets/jquery.dotdotdot.js" type="text/javascript"></script>// path assets inside www folder where I'd put the file .js
////
</head>

.html :(頁面)

////
<div id="wrapper">
 <p>"{{summary}}"</p>
</div>

.TS:

import * as $ from 'jquery';

///
ngOnInit(){
    $("#wrapper").dotdotdot({
        ellipsis : '... ',
        wrap : 'word',
        fallbackToLetter: true,
        height: null
    });
}

我收到錯誤: Uncaught (in promise): TypeError: __WEBPACK_IMPORTED_MODULE_2_jquery__(...).dotdotdot is not a function

我嘗試同時添加.js.min.js文件,但出現相同的錯誤

安裝方法與jquery相同。

安裝庫dotdotdot.js

npm install dotdotdot --save

安裝@types包

npm install --save-dev @types/dotdotdot

然后做

 import * as $ from "dotdotdot";

離子內的jQuery的正確用法是

import $ from 'jquery';

您也可以在dotdotdot中嘗試相同的方法

import dot from "dotdotdot";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM