gpt4 book ai didi

Angular2 图像未显示

转载 作者:太空狗 更新时间:2023-10-29 17:33:11 28 4
gpt4 key购买 nike

每当我在 html 中添加图像标签时,我都会执行以下操作:

<img src="../resources/img/myimg.png">

图片不显示。相反,我得到了这个显示 empty image

我试过把 <base href="/">在我的 index.html 头上,但我没有得到任何改变。这可能是什么原因造成的?我还必须做些什么才能完成这项工作?

我也试过安装 image-webpack-loader这是我的 webpack.config.js 文件的内容

var webpack = require('webpack');
var path = require('path');


// Webpack Config
var webpackConfig = {
entry: {
'polyfills': './src/polyfills.browser.ts',
'vendor': './src/vendor.browser.ts',
'main': './src/main.browser.ts',
},

output: {
path: __dirname + '/dist',
},

plugins: [
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.CommonsChunkPlugin({ name: ['main', 'vendor', 'polyfills'], minChunks: Infinity }),
],

module: {
loaders: [
// .ts files for TypeScript
{ test: /\.ts$/, loaders: ['awesome-typescript-loader', 'angular2-template-loader'] },
{ test: /\.css$/, loaders: ['to-string-loader', 'css-loader'] },
{ test: /\.html$/, loader: 'raw-loader' },
{
test: /.*\.(gif|png|jpe?g|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?{progressive:true, optimizationLevel: 7, interlaced: false, pngquant:{quality: "65-90", speed: 4}}'
]
}
]
}

};


// Our Webpack Defaults
var defaultConfig = {
devtool: 'cheap-module-source-map',
cache: true,
debug: true,
output: {
filename: '[name].bundle.js',
sourceMapFilename: '[name].map',
chunkFilename: '[id].chunk.js'
},

resolve: {
root: [ path.join(__dirname, 'src') ],
extensions: ['', '.ts', '.js']
},

devServer: {
historyApiFallback: true,
watchOptions: { aggregateTimeout: 300, poll: 1000 }
},

node: {
global: 1,
crypto: 'empty',
module: 0,
Buffer: 0,
clearImmediate: 0,
setImmediate: 0
}
};

var webpackMerge = require('webpack-merge');
module.exports = webpackMerge(defaultConfig, webpackConfig);

最佳答案

你不能离开 base href 范围,你应该将你的 Assets 移动到 src 目录中并在给出路径之后,例如 ./resources 它将是 src/resources

关于Angular2 图像未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39635649/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com