精华内容
下载资源
问答
  • }IE11 STRICT 模式下不允许分配到只读属性React项目兼容IE11的时候,报错:strict模式下不允许分配只读属性原因:直接使用e.target.style = 'xxx'解决:设置样式为 e.target.style.height = '100px'; 也就是e....

    IE下a标签里的图片会有边框

    图片加样式 img { border:none; }

    IE11 STRICT 模式下不允许分配到只读属性

    React项目兼容IE11的时候,报错:strict模式下不允许分配只读属性

    原因:直接使用e.target.style = 'xxx'

    解决:

    设置样式为 e.target.style.height = '100px'; 也就是e.target.style.styleName = val; 的形式

    将设置style改为设置一个对应样式的className名称。例如:e.target.className = 'xxx'

    浏览器全屏

    function toggleFullScreen() {

    if (!document.fullscreenElement && !document.msFullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement) {

    var docElm = document.documentElement;

    if (docElm.requestFullscreen) {

    docElm.requestFullscreen();

    }

    else if (docElm.msRequestFullscreen) { //IE

    docElm = document.body; //overwrite the element (for IE)

    docElm.msRequestFullscreen();

    }

    else if (docElm.mozRequestFullScreen) { //火狐

    docElm.mozRequestFullScreen();

    }

    else if (docElm.webkitRequestFullScreen) { //谷歌

    docElm.webkitRequestFullScreen();

    }

    } else {

    if (document.exitFullscreen) {

    document.exitFullscreen();

    }

    else if (document.msExitFullscreen) {

    document.msExitFullscreen();

    }

    else if (document.mozCancelFullScreen) {

    document.mozCancelFullScreen();

    }

    else if (document.webkitCancelFullScreen) {

    document.webkitCancelFullScreen();

    }

    }

    }

    TypeError: Cannot call a class as a function

    展开全文
  • webpack.prod.conf.js'use strict'const path = require('path')const utils = require('./utils')const webpack = require('webpack')const config = require('../config')const merge = require('webpack-merge')c...

    webpack.prod.conf.js

    'use strict'

    const path = require('path')

    const utils = require('./utils')

    const webpack = require('webpack')

    const config = require('../config')

    const merge = require('webpack-merge')

    const baseWebpackConfig = require('./webpack.base.conf')

    const CopyWebpackPlugin = require('copy-webpack-plugin')

    const HtmlWebpackPlugin = require('html-webpack-plugin')

    const ExtractTextPlugin = require('extract-text-webpack-plugin')

    const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')

    const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

    const env = require('../config/prod.env')

    const webpackConfig = merge(baseWebpackConfig, {

    module: {

    rules: utils.styleLoaders({

    sourceMap: config.build.productionSourceMap,

    extract: true,

    usePostCSS: true

    })

    },

    devtool: config.build.productionSourceMap ? config.build.devtool : false,

    output: {

    path: config.build.assetsRoot,

    filename: utils.assetsPath('js/[name].[chunkhash].js'),

    chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')

    },

    plugins: [

    // http://vuejs.github.io/vue-loader/en/workflow/production.html

    new webpack.DefinePlugin({

    'process.env': env

    }),

    new UglifyJsPlugin({

    uglifyOptions: {

    compress: {

    warnings: false

    }

    },

    sourceMap: config.build.productionSourceMap,

    parallel: true

    }),

    // extract css into its own file

    new ExtractTextPlugin({

    filename: utils.assetsPath('css/[name].[contenthash].css'),

    // Setting the following option to `false` will not extract CSS from codesplit chunks.

    // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.

    // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,

    // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110

    allChunks: true,

    }),

    // Compress extracted CSS. We are using this plugin so that possible

    // duplicated CSS from different components can be deduped.

    new OptimizeCSSPlugin({

    cssProcessorOptions: config.build.productionSourceMap

    ? { safe: true, map: { inline: false } }

    : { safe: true }

    }),

    // generate dist index.html with correct asset hash for caching.

    // you can customize output by editing /index.html

    // see https://github.com/ampedandwired/html-webpack-plugin

    // new HtmlWebpackPlugin({

    // filename: config.build.index,

    // template: 'index.html',

    // inject: true,

    // minify: {

    // removeComments: true,

    // collapseWhitespace: true,

    // removeAttributeQuotes: true

    // // more options:

    // // https://github.com/kangax/html-minifier#options-quick-reference

    // },

    // // necessary to consistently work with multiple chunks via CommonsChunkPlugin

    // chunksSortMode: 'dependency'

    // }),

    // keep module.id stable when vendor modules does not change

    new webpack.HashedModuleIdsPlugin(),

    // enable scope hoisting

    new webpack.optimize.ModuleConcatenationPlugin(),

    // split vendor js into its own file

    new webpack.optimize.CommonsChunkPlugin({

    name: 'vendor',

    minChunks (module) {

    // any required modules inside node_modules are extracted to vendor

    return (

    module.resource &&

    /\.js$/.test(module.resource) &&

    module.resource.indexOf(

    path.join(__dirname, '../node_modules')

    ) === 0

    )

    }

    }),

    // extract webpack runtime and module manifest to its own file in order to

    // prevent vendor hash from being updated whenever app bundle is updated

    new webpack.optimize.CommonsChunkPlugin({

    name: 'manifest',

    minChunks: Infinity

    }),

    // This instance extracts shared chunks from code splitted chunks and bundles them

    // in a separate chunk, similar to the vendor chunk

    // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk

    new webpack.optimize.CommonsChunkPlugin({

    name: 'app',

    async: 'vendor-async',

    children: true,

    minChunks: 3

    }),

    // copy custom static assets

    new CopyWebpackPlugin([

    {

    from: path.resolve(__dirname, '../static'),

    to: config.build.assetsSubDirectory,

    ignore: ['.*']

    }

    ])

    ].concat(utils.htmlPlugin())

    })

    if (config.build.productionGzip) {

    const CompressionWebpackPlugin = require('compression-webpack-plugin')

    webpackConfig.plugins.push(

    new CompressionWebpackPlugin({

    asset: '[path].gz[query]',

    algorithm: 'gzip',

    test: new RegExp(

    '\\.(' +

    config.build.productionGzipExtensions.join('|') +

    ')$'

    ),

    threshold: 10240,

    minRatio: 0.8

    })

    )

    }

    if (config.build.bundleAnalyzerReport) {

    const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

    webpackConfig.plugins.push(new BundleAnalyzerPlugin())

    }

    module.exports = webpackConfig

    展开全文
  • IE11告诉我,var self = this是一个...尽管如此,我可以在使用时更改它var在严格模式下不允许分配只读属性IE11'use strict';var onDocumentLoad = require('fe-client-utils/src/dom/onDocumentLoad');var onOrie...

    IE11告诉我,var self = this是一个只读变量......但是我没有在其声明点之后分配任何东西。唯一的变量是正在改变的高度。尽管如此,我可以在使用时更改它var在严格模式下不允许分配只读属性IE11

    'use strict';

    var onDocumentLoad = require('fe-client-utils/src/dom/onDocumentLoad');

    var onOrientationChange = require('fe-client-utils/src/dom/onOrientationChange');

    var faPageHeight = function() {

    };

    var FA = {

    init: function() {

    this.faAddons = document.querySelector('.fa-addons');

    this.faFooter = document.querySelector('.fa-footer');

    this.extraWideChild = document.querySelector('.extraWide > div');

    this.extraWide = document.querySelector('.extraWide');

    this.faPages = document.querySelector('.fa-pages');

    this.pageContent = document.getElementById('page-content');

    this.faPageItems = document.querySelectorAll('.fa-page');

    this.moveElements();

    this.faPageHeight();

    },

    faPageHeight: function() {

    var height = 0;

    var self = this;

    Object.keys(self.faPageItems).forEach(function (item, index) {

    height += self.faPageItems[item].offsetHeight;

    });

    height += 150;

    this.extraWideChild.style.height = height+'px';

    },

    moveElements: function() {

    this.faAddons.style = '';

    this.pageContent.appendChild(this.faAddons);

    this.pageContent.appendChild(this.faFooter);

    this.faFooter.style.display = 'block';

    }

    }

    onDocumentLoad(function() {

    FA.init();

    });

    onOrientationChange(function() {

    FA.faPageHeight();

    });

    我收到以下错误SCRIPT5045: Assignment to read-only properties is not allowed in strict mode

    根据Microsoft你不应该能够重新写一个只读属性。我不相信我。那么,为什么我会得到这个错误呢?

    只读属性

    写入只读属性

    SCRIPT5045:分配给只读属性是不允许的严格模式

    的JavaScript

    var testObj = Object.defineProperties({}, { prop1: { value: 10, writable: false // by default }, prop2: { get: function() { } } }); testObj.prop1 = 20; testObj.prop2 = 30;

    +0

    您确定这是导致错误的行吗?我无法复制那 –

    +0

    有趣的。我将用完整文件更新问题。我想知道是否将它全部封装在一个对象中是原因 –

    +0

    代码的一个最小,完整且可验证的示例,它可以证明问题会更好 –

    展开全文
  • String.prototype.startsWith) { (function() { 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` var defineProperty = (function() { // IE 8 only supports `Object.defineProperty` ...

    startsWith的mdn,这个你的看看,ie根本就没事实现这个方法,你既然使用了babel-polyfill,那么你应该是看不到startsWith这个方法的,所以应该是没有被转译,想想引得babel-polyfill是否正确,考虑使用mdn提供的转译再写一遍。

    /*! http://mths.be/startswith v0.2.0 by @mathias */

    if (!String.prototype.startsWith) {

    (function() {

    'use strict'; // needed to support `apply`/`call` with `undefined`/`null`

    var defineProperty = (function() {

    // IE 8 only supports `Object.defineProperty` on DOM elements

    try {

    var object = {};

    var $defineProperty = Object.defineProperty;

    var result = $defineProperty(object, object, object) && $defineProperty;

    } catch(error) {}

    return result;

    }());

    var toString = {}.toString;

    var startsWith = function(search) {

    if (this == null) {

    throw TypeError();

    }

    var string = String(this);

    if (search && toString.call(search) == '[object RegExp]') {

    throw TypeError();

    }

    var stringLength = string.length;

    var searchString = String(search);

    var searchLength = searchString.length;

    var position = arguments.length > 1 ? arguments[1] : undefined;

    // `ToInteger`

    var pos = position ? Number(position) : 0;

    if (pos != pos) { // better `isNaN`

    pos = 0;

    }

    var start = Math.min(Math.max(pos, 0), stringLength);

    // Avoid the `indexOf` call if no match is possible

    if (searchLength + start > stringLength) {

    return false;

    }

    var index = -1;

    while (++index < searchLength) {

    if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {

    return false;

    }

    }

    return true;

    };

    if (defineProperty) {

    defineProperty(String.prototype, 'startsWith', {

    'value': startsWith,

    'configurable': true,

    'writable': true

    });

    } else {

    String.prototype.startsWith = startsWith;

    }

    }());

    }

    展开全文
  • The back-tick character is not recognized as a Valid Character in IE11 when using the "use strict" directive while it works in other browsers, such as Chrome.What is the interpretation of this behavio...
  • { "use strict"; eval("\n\nObject.define... ^--- Column 1 这是我的webpack.config.js: 'use strict'; // Include modules and plugins const webpack = require('webpack'); const path = require('path'); ...
  • Vue.use(VueSocketIOExt, socket); 我把这四行代码注释掉之后神奇的IE不白屏了,但业务需要IE11是不能放弃长连接的,经过尝试发现是socket.io-client这个插件在使用import引入时导致的问题。 解决方法一: 1、将...
  • Use strict

    2020-12-30 11:32:52
    <div><p>Add "use strict" at the top of every javascript file to help catch errors.</p><p>该提问来源于开源项目:waterbearlang/waterbear</p></div>
  • use strict

    2019-03-22 10:57:00
    use strict;是个编译指令,意思是代码得严格符合编写规范,否则会编译报错。 转载于:https://www.cnblogs.com/lybinger/p/10576910.html
  • JavaScript Use Strict

    2020-06-29 18:28:05
    use strict”; 定义 JavaScript 代码应该以“严格模式”执行。 “use strict” 指令 “use strict” 是 JavaScript 1.8.5 中的新指令(ECMAScript version 5)。 它不算一条语句,而是一段文字表达式,更早版本的 ...
  • Use Strict Warning

    2020-12-09 08:25:54
    use strict';</code> is really necessary? <p>Here's the warning I'm receiving for a <code>create-react-app</code> project: <pre><code> ./src/smalldots/~/evee/dist/evee.js /Users/hnordt/...
  • remove use strict

    2020-12-05 10:31:06
    <div><p>Can't call super when use strict is in place</p><p>该提问来源于开源项目:yeoman/generator-polymer</p></div>
  • Use strict everywhere

    2020-12-02 07:33:13
    <div><p>Added <code>use strict</code> declarations to all files in <em>archetype</em> and <em>lib/index.js, for consistency. <p>I might have deleted a space or two in the process. Let me know if I ...
  • Javascript use strict

    2017-03-14 16:45:04
    ECMAscript 5添加了第...use strict";  console.log("这是严格模式。");  &lt;/script&gt;   针对单个函数 function strict(){  "use strict";  return "这是严格模...
  • use strict output twice

    2020-12-01 19:41:51
    use strict'; </code></pre> <p>Output: <pre><code> js 'use strict'; 'use strict'; </code></pre> <p>:cry: </p><p>该提问来源于开源项目:esperantojs/esperanto</p></div>
  • Fix use strict detection

    2021-01-11 06:54:59
    - Recognize Use Strict directive in the middle of directive prologue. - Do not recognize Use Strict if it contains escape sequences (see 14.1 Directive Prologues and the Use Strict Directive) <p>...
  • <p>The purpose of the use strict and use warnings tests are, I think, to note the fact that you haven't got them in your code, not actually note every line of code in the source that fails to be...
  • use strict redundant now

    2020-12-30 04:18:22
    <div><p>use 5.012, unlike use 5.010, already implies use strict. Did you mean to include it anyway?</p><p>该提问来源于开源项目:chromatic/modern_perl_book</p></div>
  • use strict 介绍

    2013-04-25 11:22:09
    什么场合要用 use strict 当你的程序有一定的行数时,尤其是在一页放不下时,或者是你找不到发生错误的原因时。 为什么要用 use strict? 众多的原因之一是帮你寻找因为错误拼写造成的错误。比如错误使用了'$...
  • Use strict match

    2020-12-09 06:35:41
    <div><p>该提问来源于开源项目:0xcert/framework</p></div>
  • Use strict comparison

    2020-12-08 18:15:33
    <div><p>该提问来源于开源项目:symfony/symfony-docs</p></div>

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 18,321
精华内容 7,328
关键字:

strictuse