你可能需要一个合适的加载器来处理这种文件类型打字稿
you may need an appropriate loader to handle this file type typescript
我正在尝试执行此脚本
$(document).ready(() => { $('.iqdropdown').iqDropdown({ [options] }); });
这是一个 Jquery 插件 item-quantity-dropdown jQuery 插件 (https://github.com/reservamos/item-quantity-dropdown#javascript),
并且此代码是根据此插件的说明编写的
但是 cmd 给我写这个
ERROR in ./src/scripts/index.js 169:42 Module parse failed: Unexpected token (169:42) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See htt://webpack.js.org/concepts#loaders
但是我有 TS-loader(我的 WebPack 配置)
const { CheckerPlugin } = require('awesome-typescript-loader');
module: {
rules: [
{
test: /\.pug$/,
use: [
'pug-loader'
]
},
{
test: /\.scss|css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
}
]
},
{
enforce: 'pre',
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'eslint-loader'
}, {
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /(node_modules)/
},
并且我将 tsconfig 中的目标更改为 es2020
"module": "commonjs",
"target": "es2020",
"outDir": "./dist",
"lib": ["es2016", "dom"]`|
我也尝试将 lib 更改为 es2020,但它什么也没给)
我有 TypeScript v.4
不安装babel我能做什么?请帮助)
问题解决了。弗雷德·斯塔克 (https://whosebug.com/users/992964/fred-stark)
在评论中帮助我:
in docs it's a common convention to mark something as optional by
wrapping it with square brackets. I'm guessing that's what they mean,
since this is invalid syntax. Try the method call with no arguments:
$('.iqdropdown').iqDropdown(); and see if that works – Fred Stark 13
hours ago
It's unfortunate they used the convention in a code snippet instead of
in comments or text. They really should only put valid working code in
code snippets. – Fred Stark 13 hours ago
God! $('.iqdropdown').iqDropdown(); works! Now please can you tell me how i
need to write my options inside this function? – Void0000 13 hours ago
you pass an object with the options as a parameter:
$('.iqdropdown').iqDropdown({ maxItems: 10 }); – Fred Stark 13 hours
ago
我正在尝试执行此脚本
$(document).ready(() => { $('.iqdropdown').iqDropdown({ [options] }); });
这是一个 Jquery 插件 item-quantity-dropdown jQuery 插件 (https://github.com/reservamos/item-quantity-dropdown#javascript), 并且此代码是根据此插件的说明编写的
但是 cmd 给我写这个
ERROR in ./src/scripts/index.js 169:42 Module parse failed: Unexpected token (169:42) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See htt://webpack.js.org/concepts#loaders
但是我有 TS-loader(我的 WebPack 配置)
const { CheckerPlugin } = require('awesome-typescript-loader');
module: {
rules: [
{
test: /\.pug$/,
use: [
'pug-loader'
]
},
{
test: /\.scss|css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
}
]
},
{
enforce: 'pre',
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'eslint-loader'
}, {
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /(node_modules)/
},
并且我将 tsconfig 中的目标更改为 es2020
"module": "commonjs",
"target": "es2020",
"outDir": "./dist",
"lib": ["es2016", "dom"]`|
我也尝试将 lib 更改为 es2020,但它什么也没给)
我有 TypeScript v.4
不安装babel我能做什么?请帮助)
问题解决了。弗雷德·斯塔克 (https://whosebug.com/users/992964/fred-stark) 在评论中帮助我:
in docs it's a common convention to mark something as optional by wrapping it with square brackets. I'm guessing that's what they mean, since this is invalid syntax. Try the method call with no arguments: $('.iqdropdown').iqDropdown(); and see if that works – Fred Stark 13 hours ago
It's unfortunate they used the convention in a code snippet instead of in comments or text. They really should only put valid working code in code snippets. – Fred Stark 13 hours ago
God! $('.iqdropdown').iqDropdown(); works! Now please can you tell me how i need to write my options inside this function? – Void0000 13 hours ago
you pass an object with the options as a parameter: $('.iqdropdown').iqDropdown({ maxItems: 10 }); – Fred Stark 13 hours ago