链接不再有效:例如https://unpkg.com/vue@3.2.30/dist/vue.min.js

links not working anymore: e.g. https://unpkg.com/vue@3.2.30/dist/vue.min.js

来自 unpkg 的 CDN-link 不再工作。其他旧版本也不起作用。

https://unpkg.com/vue@3.2.30/dist/vue.min.js

我可以使用哪个 link 来代替?

谢谢

<script src="https://unpkg.com/vue@3.2.30/dist/vue.global.prod.js"></script>
<!-- <script src="//unpkg.com/vue@latest/dist/vue.min.js"></script> -->

<script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.js"></script>

<script src="https://unpkg.com/vue-router"></script>

<script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue-icons.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

这些是我加载的始终有效的资源。我该如何替换它们?

对于 Vue 3,生产缩小文件有 .prod.js as their file extension。但看起来您实际上需要 Vue 2,因为您使用的是没有固定版本说明符的 CDN 链接:

<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
                               ^^^ ⛔️ defaults to latest
<script src="https://unpkg.com/vue@latest/dist/vue.min.js"></script>
                               ^^^^^^^^^^ ⛔️ no longer Vue 2

Vue 最近将 vue@latest 更新为 version 3。同样,vue-router@latest也更新到了版本4,只兼容Vue 3.

要坚持使用 Vue 2 兼容包,请在 CDN URL 中使用以下版本说明符:

<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>
                                     
<script src="https://unpkg.com/vue-router@3.5.3/dist/vue-router.min.js"></script>
                                            
<script src="https://unpkg.com/bootstrap-vue@2.21.2/dist/bootstrap-vue.min.js"></script>
                                               

为避免将来 latest 标签更新出现这些意外故障,您应该始终在生产中为 CDN 链接使用特定的固定版本。

new Vue({
  data: {
    counter: 0,
  },
}).$mount('#app')
<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>
<script src="https://unpkg.com/vue-router@3.5.3/dist/vue-router.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@2.21.2/dist/bootstrap-vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
<script src="https://unpkg.com/axios@0.25.0/dist/axios.min.js"></script>

<div id="app">
  <div>counter: {{ counter }}</div>
  <button @click="counter++">+</button>
</div>