{"id":3440,"date":"2024-11-10T14:41:49","date_gmt":"2024-11-10T06:41:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3440\/"},"modified":"2024-11-10T14:41:49","modified_gmt":"2024-11-10T06:41:49","slug":"vue-js-%e5%a6%82%e4%bd%95%e5%bc%95%e5%85%a5js","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3440\/","title":{"rendered":"vue.js \u5982\u4f55\u5f15\u5165js"},"content":{"rendered":"<blockquote><p>\n  \u5728 vue.js \u4e2d\u5f15\u5165 js\uff1a\u76f4\u63a5\u5f15\u5165\uff1a html \u4e2d\u4f7f\u7528 \u6807\u7b7e\u3002\u901a\u8fc7 vue.config\uff1a \u5728 vue.js \u914d\u7f6e\u4e2d\u8bbe\u7f6e\u5168\u5c40\u5f15\u5165\u3002\u901a\u8fc7\u6a21\u5757\u5bfc\u5165\uff1a \u4f7f\u7528\u6a21\u5757\u6784\u5efa\u5de5\u5177\uff08\u5982 webpack\uff09\u8fdb\u884c\u5bfc\u5165\u3002\u7ec4\u4ef6\u5185\u5f15\u5165\uff1a \u4f7f\u7528 \u3001vue.component() \u6216\u6a21\u5757\u5bfc\u5165\uff0c\u5c06 js \u5305\u542b\u5728\u7ec4\u4ef6\u4e2d\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/08\/2024110812212122437.jpg\" class=\"aligncenter\" title=\"vue.js \u5982\u4f55\u5f15\u5165js\u63d2\u56fe\" alt=\"vue.js \u5982\u4f55\u5f15\u5165js\u63d2\u56fe\" \/><\/p>\n<h2>\u5982\u4f55\u5728 Vue.js \u4e2d\u5f15\u5165 JS<\/h2>\n<p><strong>\u76f4\u63a5\u5f15\u5165<\/strong><\/p>\n<p>\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u5728 HTML \u4e2d\u76f4\u63a5\u5305\u542b &lt;script&gt; \u6807\u7b7e\uff1a&lt;\/script&gt;<\/p>\n<pre>&lt;script src=\"path\/to\/your_script.js\"&gt;&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u901a\u8fc7 Vue.config<\/strong><\/p>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u5728 Vue.js \u914d\u7f6e\u5bf9\u8c61\u4e2d\u5f15\u5165 JS \u6587\u4ef6\uff0c\u8fd9\u9002\u7528\u4e8e\u60a8\u5e0c\u671b\u5728\u6240\u6709 Vue \u5b9e\u4f8b\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u811a\u672c\u7684\u60c5\u51b5\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>Vue.config.productionTip = false\nVue.config.devtools = false\nVue.config.silent = true\nVue.config.ignoredElements = []\nVue.config.keyCodes = {}\nVue.config.optionMergeStrategies = {}\nVue.config.errorHandler = function(err, vm, info) {}\nVue.config.warnHandler = function(msg, vm, trace) {}\nVue.config.performance = true\nVue.config.devtools = true\nVue.config.async = true\nVue.config.warnHandler = function(msg, vm, trace) {}\nVue.config.errorHandler = function(err, vm, info) {}\nVue.config.performance = true<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u901a\u8fc7\u6a21\u5757\u5bfc\u5165<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u6a21\u5757\u6784\u5efa\u5de5\u5177\uff08\u5982 Webpack \u6216 Rollup\uff09\uff0c\u5219\u53ef\u4ee5\u50cf\u8fd9\u6837\u5bfc\u5165 JS \u6587\u4ef6\uff1a<\/p>\n<pre>import myScript from 'path\/to\/your_script.js'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7ec4\u4ef6\u5185\u5f15\u5165<\/strong><\/p>\n<p>\u8981\u5c06 JS \u6587\u4ef6\u5305\u542b\u5728\u7ec4\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u9009\u9879\uff1a<\/p>\n<ul>\n<li> <strong>\u4f7f\u7528 &lt;script&gt; \u6807\u7b7e\uff1a&lt;\/script&gt;<\/strong> \u5c06 &lt;script&gt; \u6807\u7b7e\u653e\u5728\u7ec4\u4ef6\u6a21\u677f\u4e2d\u3002&lt;\/script&gt; <\/li>\n<li> <strong>\u901a\u8fc7 Vue.component()\uff1a<\/strong> \u5728\u6ce8\u518c\u7ec4\u4ef6\u65f6\uff0c\u5c06 JS \u6587\u4ef6\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 Vue.component()\u3002<\/li>\n<li> <strong>\u901a\u8fc7\u6a21\u5757\u5bfc\u5165\uff1a<\/strong> \u4f7f\u7528 import \u8bed\u53e5\u5bfc\u5165 JS \u6587\u4ef6\uff0c\u7136\u540e\u5c06\u5176\u4f5c\u4e3a\u7ec4\u4ef6\u9009\u9879\u4e2d components \u5c5e\u6027\u7684\u503c\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u5f15\u5165\u7684 JS \u6587\u4ef6\u76f8\u5bf9\u4e8e\u60a8\u7684 HTML \u6587\u4ef6\u6216\u6a21\u5757\u6784\u5efa\u5de5\u5177\u7684\u914d\u7f6e\u8def\u5f84\u6b63\u786e\u3002<\/li>\n<li>\u9075\u5b88 JS \u5bfc\u5165\u6700\u4f73\u5b9e\u8df5\uff0c\u4f8b\u5982\u4f7f\u7528\u6a21\u5757\u5bfc\u5165\u800c\u4e0d\u662f\u5168\u5c40\u53d8\u91cf\u3002<\/li>\n<li>\u6d4b\u8bd5\u60a8\u7684\u4ee3\u7801\u4ee5\u786e\u4fdd\u5f15\u5165\u7684 JS \u6b63\u786e\u5de5\u4f5c\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f.js \u5982\u4f55\u5f15\u5165js\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 vue.js \u4e2d\u5f15\u5165 js\uff1a\u76f4\u63a5\u5f15\u5165\uff1a html \u4e2d\u4f7f\u7528 \u6807\u7b7e\u3002\u901a\u8fc7 vue.config\uff1a \u5728 vue.js \u914d\u7f6e\u4e2d\u8bbe\u7f6e\u5168\u5c40\u5f15\u5165\u3002\u901a\u8fc7\u6a21\u5757\u5bfc\u5165\uff1a \u4f7f\u7528\u6a21\u5757\u6784\u5efa\u5de5\u5177\uff08\u5982 webpack\uff09\u8fdb\u884c\u5bfc\u5165\u3002\u7ec4\u4ef6\u5185\u5f15\u5165\uff1a \u4f7f\u7528 \u3001vue.component() \u6216\u6a21\u5757\u5bfc\u5165\uff0c\u5c06 js \u5305\u542b\u5728\u7ec4\u4ef6\u4e2d\u3002 \u5982\u4f55\u5728 Vue.js \u4e2d\u5f15\u5165 JS \u76f4\u63a5\u5f15\u5165 \u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u5728 HTML \u4e2d\u76f4\u63a5\u5305\u542b &lt;script&gt; \u6807\u7b7e\uff1a&lt;\/script&gt; &lt;script src=&#8221;path\/to\/your_script.js&#8221;&gt;&lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7 Vue.config \u60a8\u8fd8\u53ef\u4ee5\u5728 Vue.js \u914d\u7f6e\u5bf9\u8c61\u4e2d\u5f15\u5165 JS \u6587\u4ef6\uff0c\u8fd9\u9002\u7528\u4e8e\u60a8\u5e0c\u671b\u5728\u6240\u6709 Vue \u5b9e\u4f8b\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u811a\u672c\u7684\u60c5\u51b5\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b Vue.config.productionTip = false Vue.config.devtools = false Vue.config.silent = true Vue.config.ignoredElements = [] Vue.config.keyCodes = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3440","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=3440"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3440\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}