vue typescript cdn引入jquery声明使用丨技术开发分享录

vue typescript cdn引入jquery声明使用

{{ detail.nickname }}

转载 翻译 {{ formatTime(detail.create_time) }} 字数 {{ detail.content && detail.content.length }} 阅读 {{ detail.read_num }} {{ formatTag(v) }}

"在public/index.html引入jquery\n\n```markup{9}\n<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\n    <link rel=\"icon\" href=\"<%= BASE_URL %>favicon.ico\">\n    <title><%= htmlWebpackPlugin.options.title %></title>\n    <script src=\"https://www.fenxianglu.cn/vendor/jquery.min.js\"></script>\n  </head>\n  <body>\n    <noscript>\n      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>\n    </noscript>\n    <div id=\"app\"></div>\n    <!-- built files will be auto injected -->\n  </body>\n</html>\n```\n\n## 一、在shims-tsx.d.ts声明\n\n> shims-tsx.d.ts文件在项目构建完自动生成\n\n```typescript\ndeclare global {\n    var $: any;\n}\n```\n\n## 二、在.vue中声明\n\n```markup\n<template>\n  <div>\n    <strong>hello world</strong>\n  </div>\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport Component from 'vue-class-component';\n\ndeclare  var $: any;\n\n@Component\nexport default class Home extends Vue {\n  mounted() {\n    $('strong').css('color', '#f00');\n  }\n}\n</script>\n```"
PS:写作不易,如要转裁,请标明转载出处。

如果此篇对您有帮助,可小额赞助,以兹鼓励!

猜你想看