&引用;ReferenceError:“未定义:”;将javascript添加到vue组件时<;脚本>;标签
尝试将代码添加到自动展开文本框时出现此错误-来自此代码笔:。 我需要以不同的方式添加它吗? 它当前位于vue组件文件中的脚本标记之间&引用;ReferenceError:“未定义:”;将javascript添加到vue组件时<;脚本>;标签,javascript,Javascript,尝试将代码添加到自动展开文本框时出现此错误-来自此代码笔:。 我需要以不同的方式添加它吗? 它当前位于vue组件文件中的脚本标记之间 Uncaught ReferenceError: $ is not defined at eval (Pastes.vue?58dd:23) at Object../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/selector.js?type=script
Uncaught ReferenceError: $ is not defined
at eval (Pastes.vue?58dd:23)
at Object../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/pages/pastes/Pastes.vue (app.js:782)
at __webpack_require__ (app.js:679)
at fn (app.js:89)
at eval (Pastes.vue?fa7c:1)
at Object../src/components/pages/pastes/Pastes.vue (app.js:1220)
at __webpack_require__ (app.js:679)
at fn (app.js:89)
at eval (index.js?3672:1)
at Object../src/router/index.js (app.js:1252)
确保您正在加载jquery库,您可以按照这个或这个进行操作。我使用了这段代码,这段代码运行得非常好
注意:在笔设置->JS选项卡中,它包括
//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.JS
var autoExpand = function (field) {
// Reset field height
field.style.height = 'inherit';
// Get the computed styles for the element
var computed = window.getComputedStyle(field);
// Calculate the height
var height = parseInt(computed.getPropertyValue('border-top-width'), 10)
+ parseInt(computed.getPropertyValue('padding-top'), 10)
+ field.scrollHeight
+ parseInt(computed.getPropertyValue('padding-bottom'), 10)
+ parseInt(computed.getPropertyValue('border-bottom-width'), 10);
field.style.height = height + 'px';
};
document.addEventListener('input', function (event) {
if (event.target.tagName.toLowerCase() !== 'textarea') return;
autoExpand(event.target);
}, false);