2

使用 Bootstrap-select 通过多选下拉菜单创建组,搜索启用面临以下错误 IInstance 类型上不存在属性“selectpicker”

环境:Typescript 2.2 angular 2.0 Jquery 2.2.4 Jquery-ts 2.1.1

请找到包含错误消息的附件图片

4

2 回答 2

1

安装类型bootstrap-select并确保依赖项jquerybootstrapbootstrap-select在您的代码中导入以防止任何运行时错误:

npm install --save-dev @types/bootstrap-select
于 2017-04-24T06:26:51.483 回答
0
 isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('vendor.css');

module.exports = {
    resolve: {
        extensions: [ '', '.js' ]
    },
    module: {
        loaders: [
            { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
            { test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) }
        ]
    },
    entry: {
        vendor: [
            '@angular/common',
            '@angular/compiler',
            '@angular/core',
            '@angular/http',
            '@angular/platform-browser',
            '@angular/platform-browser-dynamic',
            '@angular/router',
            '@angular/platform-server',
            '@type/bootstrap-select',
            'angular2-universal',
            'angular2-universal-polyfills',
            'bootstrap',
            'bootstrap/dist/css/bootstrap.css',
            'bootstrap-select',
            'bootstrap-select/dist/css/bootstrap-select.css',
            'es6-shim',
            'es6-promise',
            'font-awesome/css/font-awesome.css',
            'jquery',
            'jquery-ts',
            'zone.js',
        ]
    },
    output: {
        path: path.join(__dirname, 'wwwroot', 'dist'),
        filename: '[name].js',
        library: '[name]_[hash]',
    },
    plugins: [
        extractCSS,
        new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.DllPlugin({
            path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
            name: '[name]_[hash]'
        })
    ].concat(isDevBuild ? [] : [
        new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
    ])
};
于 2017-04-24T06:52:29.847 回答