版本 2.5.11
复制链接 https://jsfiddle.net/ranjs/eh10wju7/
复制步骤:
在Google Chrome浏览器中,它工作正常,但在Firefox中,我收到错误消息:
'TypeError:未定义不是构造函数[了解详情]
并且屏幕上什么都没有显示。
[Show/hide message details.] TypeError: undefined is not a constructor[Learn More] build.js:1:182494
<anonymous>
http://localhost:25555/static/dist/build.js:1:182494
<anonymous>
http://localhost:25555/static/dist/build.js:1:181955
r
http://localhost:25555/static/dist/build.js:1:96
<anonymous>
http://localhost:25555/static/dist/build.js:1:4377
r
http://localhost:25555/static/dist/build.js:1:96
<anonymous>
http://localhost:25555/static/dist/build.js:1:247068
r
http://localhost:25555/static/dist/build.js:1:96
<anonymous>
http://localhost:25555/static/dist/build.js:1:457
<anonymous>
http://localhost:25555/static/dist/build.js:1:2
What is expected?
App shows normaly
实际上发生了什么?出现错误,但不显示任何内容。
我上传了main.js
,这就是我的package.json
:
'{
"name": "chatbotmariana",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "Ranieri Abreu Silva Junior <rabreu@indracompany.com>",
"license": "MIT",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"prod": "cross-env NODE_ENV=development webpack-dev-server --port 80 --hot --host 0.0.0.0"
},
"dependencies": {
"axios": "^0.18.0",
"compression": "^1.7.3",
"express-minify": "^1.0.0",
"jquery": "^3.3.1",
"popper.js": "^1.14.4",
"vue": "^2.5.17",
"vue-resource": "^1.5.1",
"vue-router": "^3.0.1"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"vue-loader": "^13.7.3",
"vue-template-compiler": "^2.5.17",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.11.3"
}
}
我正在使用JavaScript,但没有tsconfig
。
.bablrc:
{
"presets": [
["env", { "modules": false }],
"stage-3"
]
}
webpack.config.js
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
loaders: [
{
test: /\.css$/,
loader: 'style!css'
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
},
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream"
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file"
},{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=image/svg+xml"
}
],
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
}, {
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ] // <= Order is very important
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery'
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
答案 0 :(得分:0)
我找到了。
const SpeechRecognition =
window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.lang = "pt-BR";
recognition.interimResults = false;
recognition.maxAlternatives = 1;
此代码在Firefox中不起作用