重新访问无法运行的旧mini Vue项目

zour9fqk  于 2022-11-17  发布在  Vue.js
关注(0)|答案(2)|浏览(152)

大家好,我正在重温一个老项目,我还没有玩弄在相当长的一段时间。
我是第一次尝试Vue,并试图创建一个射箭计算器(动能/速度/等)。不想做一个完整的Vue应用程序设置,所以我只是使用了一个cdn链接。它最初是完全功能,但现在我再次检查它,我发现结果不再填充时,数字已添加。我链接了一个codepen在这里-〉https://codepen.io/gchis66/pen/ZERKBwd

new Vue({
     el: "#archery-calculator",
     data() {
      return {
         IBO:'',
         drawLength:'',
         drawWeight:'',
         arrowWeight:'',
         additionalWeight:'',
         arrowLength:'',
         distanceFromNock:''
      }
     },
     computed: {
         calcVelocity: function(e){
             
             let ibo = this.IBO;
             let dL = this.drawLength;
             let dW = this.drawWeight;
             let aW = this.arrowWeight;
             let adW = this.additionalWeight;
             let result = ibo + (dL - 30) * 10 - adW / 3 + Math.min(0,-(aW - (5*dW))/ 3);
             let truncated = Math.round(result);
             if (truncated > 0){
                 return truncated;
             }else{
                 return 0;
             }
             
         },
         calcKineticEnergy: function(){
             let ibo = this.IBO;
             let dL = this.drawLength;
             let dW = this.drawWeight;
             let aW = this.arrowWeight;
             let adW = this.additionalWeight;
             let s = ibo + (dL - 30) * 10 - adW / 3 + Math.min(0,-(aW - (5*dW))/ 3);
             let result = (aW*(s**2))/450800;
             let truncated = Math.round(result);
             return truncated;
 
         },
         calcMomentum: function(){
             let ibo = this.IBO;
             let dL = this.drawLength;
             let dW = this.drawWeight;
             let aW = this.arrowWeight;
             let adW = this.additionalWeight;
             let velocity = ibo + (dL - 30) * 10 - adW / 3 + Math.min(0,-(aW - (5*dW))/ 3);
             let momentum = (aW * velocity)/225400;
             let truncated = momentum.toFixed(2);
             return truncated;
         },
         calcFoc: function(){
             let aL = this.arrowLength;
             let dN = this.distanceFromNock;
             let result = ((100 * (dN-(aL/2)))/aL);
             if (result > 0) {
                 return result.toFixed(1);
             }
             else{
                 return 0;
             }
         }
     }
 });

我收到错误“Vue不是一个构造函数”。可能有一个明显的问题,但我的时间短,决定问这里,因为这个计算器是活在一个网站上。
任何帮助都将不胜感激!

8gsdolmq

8gsdolmq1#

您正在使用Vue 3。在codepen配置中,请使用版本2中的Vue:https://cdnjs.cloudflare.com/ajax/libs/vue/2.7.8/vue.min.js .
Vue 3中的应用程序设置与Vue 2中的不同,因此出现错误Vue is not a constructor

xxls0lw8

xxls0lw82#

这是Vue2项目,您正在尝试加载Vue3。只需切换到Vue2或为Vue3重写它。
请看here

相关问题