9项目无法播放功能

9项目无法播放功能

本文介绍了Ionic 5 Angular 9项目无法播放功能,但会从外部Javascript文件发出警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一个Ionic 5 Angular 9项目.我想调用外部javascript文件.这些文件被称为通缉,因为我放了一个警报,它显示了警报为通缉,但没有调用jquery函数

Hello i have an Ionic 5 Angular 9 project. I want to call external javascript files. The files are being called as wanted because i put an alert and it shows the alert as wanted but it doesn't call the jquery functions

angular.json

angular.json

 "scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "node_modules/jquery/dist/jquery.js",
          "node_modules/bootstrap/dist/js/bootstrap.min.js",
          "src/assets/js/bootstrap.min.js",
          "src/assets/js/custon.js",
          "src/assets/js/charts.js",
          "src/assets/js/colors.js",
          "src/assets/js/filters.js",
          "src/assets/js/global.js",
          "src/assets/js/idangerous.swiper.min.js",
          "src/assets/js/isotope.pkgd.min.js",
          "src/assets/js/jqColorPicker.js",
          "src/assets/js/jquery-2.1.4.min.js",
          "src/assets/js/jquery-ui.js",
          "src/assets/js/jquery-ui.min.js",
          "src/assets/js/jquery.canvasjs.min.js",
          "src/assets/js/jquery.countTo.js",
          "src/assets/js/jquery.easy-autocomplete.min.js",
          "src/assets/js/jquery.mixitup.js",
          "src/assets/js/jquery.viewportchecker.min.js",
          "src/assets/js/magnific.js",
          "src/assets/js/map.js",
          "src/assets/js/script.js",
          **"src/assets/js/sorttable.js",**
          "src/assets/js/wow.js"
        ]

sortable.js

sortable.js

(function($){
alert('welcome');
$.extend({tablesorter:new
function(){var parsers=[],widgets=[];this.defaults= {cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d).....

推荐答案

您可以通过将JavaScript文件添加到index.html文件中来轻松调用它.

You can easily call javascript files by adding it in index.html file.

<script src="/js/sortable.js"></script>

如果要在ts文件中使用javascript文件

If you want to use your javascript file in ts files

1-将这些导出文件添加到test.js文件中

1- Add these exports in test.js file

export { nodes, edges, container, data, options, network };

2-然后将其导入ts文件

2- then import it in ts file

import "/js/sortable";

如果要在ngOnInit中使用jquery元素,则必须将其强制转换为任何元素.

If you want to use jquery elements inside ngOnInit you have to cast it to any.

if (($('#container-mix') as any).length) {
  ($('#container-mix') as any).mixItUp({
    animation: {
      duration: 400,
      effects: 'fade translateZ(-360px) stagger(34ms)',
      easing: 'ease',
    },
  });
}

这篇关于Ionic 5 Angular 9项目无法播放功能,但会从外部Javascript文件发出警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 16:03