最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

semantic-ui-react圖像組件不顯示圖像的問(wèn)題

標(biāo)簽:
JavaScript

问题

React提供了一种相当科学的开发Web应用前端视图层的技术,借助于semantic-ui for React可以很容易地搭建起常用网页开发中的UI组件,但是最近在分析其提供的各种组件时发现Image组件存在一个小问题,记录于此。

我最初代码形式

import React from 'react'import {    Grid,    Image,} from 'semantic-ui-react'const ImageExampleLink = () => (    <Grid container stackable verticalAlign='middle'>        <Grid.Row>            <Grid.Column  floated='left' width={4}>                <Image                    bordered                    rounded                    size='small'                    src='./help.png'                />            </Grid.Column>            <Grid.Column floated='right' width={4}>                <Image                    bordered                    rounded                    size='small'                    src='./help.png'                />            </Grid.Column>        </Grid.Row>        <Grid.Row>            <Grid.Column  floated='right' >                <Image                    size='mini'                    avatar                    src='./help.png'                />            </Grid.Column>        </Grid.Row>    </Grid>)export default ImageExampleLink

其中图像文件的路径位置没有问题,但是运行中发现图像死活不显示,只显示一个通用的系统提供的那种你常见的占位符形式。
然后,通过google浏览器搜索分析,发现了一个看似相近的题目「Semantic-UI Image properties not working with semantic-ui-react」(https://stackoverflow.com/questions/44609711/semantic-ui-image-properties-not-working-with-semantic-ui-react)。
其实,上面的问题与我的不一样,semantic-ui-react系统所使用的css文件我是的确导入了。我的有关安装及使用方式是这样的:


npm install semantic-ui-react --save
npm install semantic-ui-css

npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

然后在index.js里导入
import 'semantic-ui-css/semantic.min.css';

上述步骤没有什么问题,因为我使用其他许多组件(我是在app.js中进行测试使用各种组件的)是没有问题的。


在上面的stackoverflow.com问题中,那位回答者的回答是“Semantic UI React requires a Semantic UI' CSS, you forgot to setup it, here is instuctions.”。我跟踪这个链接过去,只是简单地转入了官方展示网站,没有什么,我早就比较熟悉这个地方了。但是,受到此处的一点启动,我把代码中的src属性的地址形式变换了一个,使用了JSX语言推荐的如下表达形式。

改进后代码形式

import React from 'react'import {    Grid,    Image,} from 'semantic-ui-react'import help from './help.png';const ImageExampleLink = () => (    <Grid container stackable verticalAlign='middle'>        <Grid.Row>            <Grid.Column  floated='left' width={4}>                <Image                    bordered                    rounded                    size='small'                    src={help}                />            </Grid.Column>            <Grid.Column floated='right' width={4}>                <Image                    bordered                    rounded                    size='small'                    src={help}                />            </Grid.Column>        </Grid.Row>        <Grid.Row>            <Grid.Column  floated='right' >                <Image                    size='mini'                    avatar                    src={help}                />            </Grid.Column>        </Grid.Row>    </Grid>)export default ImageExampleLink

请注意上面代码最初的import语句和改进后的Image组件的src属性值的表达方式。再试运行,OK!

有关这种原因的深层官方解决仍然在探索中,有此问题的,可暂时参考一下。

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫(xiě)下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消