gpt4 book ai didi

javascript - 未捕获的类型错误 : undefined is not a function gauge. js

转载 作者:行者123 更新时间:2023-11-29 19:40:00 25 4
gpt4 key购买 nike

我正在尝试使用 gauge.js插件与我的 Rails 4 应用程序,但是当我尝试访问主页时,我的控制台中出现了 Uncaught TypeError: undefined is not a function 错误。

这是我在 application.js 中的内容:

//= require jquery
//= require gauge.min.js

这是我的 index.html View 中的内容:

<script>
jQuery(document).ready(function(){
var opts = {
lines: 12, // The number of lines to draw
angle: 0.15, // The length of each line
lineWidth: 0.44, // The line thickness
pointer: {
length: 0.9, // The radius of the inner circle
strokeWidth: 0.035, // The rotation offset
color: '#000000' // Fill color
},
limitMax: 'false', // If true, the pointer will not go past the end of the gauge
colorStart: '#6FADCF', // Colors
colorStop: '#8FC0DA', // just experiment with them
strokeColor: '#E0E0E0', // to see which ones work best for you
generateGradient: true
};
var target = document.getElementById('foo'); // your canvas element
var gauge = new Gauge(target).setOptions(opts); // create sexy gauge!
gauge.maxValue = 3000; // set max gauge value
gauge.animationSpeed = 32; // set animation speed (32 is default value)
gauge.set(1250); // set actual value
})
</script>

我搜索了这个错误,发现这是脚本加载顺序错误的问题,所以我想知道这是否与 Rails 4 turbolinks 有关,因为我在其他部分加载 JS 时遇到问题我的应用程序。

最佳答案

以前我有:

<div id="foo"></div>

它需要是:

<canvas id="foo"></canvas>

关于javascript - 未捕获的类型错误 : undefined is not a function gauge. js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23728659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com