CSS - 在一个元素中加下划线,删除线和上划线(包含样式和颜色)(CSS - Underline, strikethrough and overline (with styles and colors) in one element)
我想用三行(下划线,删除线和上划线) 只有一个
<span>
像这样:(这只是一个例子,我想动态地改变它)
但是我不能在这样一个元素中使用几个text-decorations
:span { text-decoration: overline dotted green; text-decoration: line-through wavy aqua; text-decoration: underline double red; }
我如何使用一个
<span>
来做到这一点? 也许我可以使用::after
和::before
或其他语言如SASS或LESS?
感谢帮助。I want to get only one
<span>
with three lines (underline, strikethrough and overline) like this: (That is only example, I want to change it dynamically)
but I can't use fewtext-decorations
in one element like this:span { text-decoration: overline dotted green; text-decoration: line-through wavy aqua; text-decoration: underline double red; }
How can I do this using one
<span>
? Maybe I can use::after
and::before
or another languages like SASS or LESS?
Thanks for help.
原文:https://stackoverflow.com/questions/45932420
最满意答案
你为什么不像下面那样把动作作为一个
const
? 使用对象而不是单个值存储状态也非常方便。action.js
/*Action*/ export const DRAWER_POPOUT_MENU_STATUS = 'DRAWER_POPOUT_MENU_STATUS'; /*Action Creator*/ export const setDrawerPopOutMenuStatus = { type: DRAWER_POPOUT_MENU_STATUS, }
reducers.js
import { combineReducers } from 'redux'; import { DRAWER_POPOUT_MENU_STATUS } from './action'; const initialState = { someName: true, }; const setDrawerPopOutMenuStatus = (state = initialState, action) => { switch (action.type) { case DRAWER_POPOUT_MENU_STATUS: let newState = {}; newState['someName'] = !state.someName; return Object.assign({}, state, newState); default: return state; } }
这使得以后在项目更大时更容易管理。
Why don't you make action as a
const
like below? Also storing states using object not a single value would be much convenient.action.js
/*Action*/ export const DRAWER_POPOUT_MENU_STATUS = 'DRAWER_POPOUT_MENU_STATUS'; /*Action Creator*/ export const setDrawerPopOutMenuStatus = { type: DRAWER_POPOUT_MENU_STATUS, }
reducers.js
import { combineReducers } from 'redux'; import { DRAWER_POPOUT_MENU_STATUS } from './action'; const initialState = { someName: true, }; const setDrawerPopOutMenuStatus = (state = initialState, action) => { switch (action.type) { case DRAWER_POPOUT_MENU_STATUS: let newState = {}; newState['someName'] = !state.someName; return Object.assign({}, state, newState); default: return state; } }
This makes it easier to manage later on when the project is bigger.
相关问答
更多-
正如Rick Jolly在你的问题的评论中提到的那样,你的onSearchPressed()函数实际上并没有调度那个动作,因为addToSaved()只是返回一个动作对象 - 它不会发送任何东西。 如果要从组件调度操作,则应使用react-redux将组件连接到redux。 例如: const { connect } = require('react-redux') class MainView extends Component { onSearchPressed() { this.prop ...
-
在您的Search.js组件中,看起来您使用的connect不正确。 const Search = () => { const {search,value} = this.props return (search(event.target.value)}>) } const mapDispatch ...
-
我不能完全确定,但根据你的描述说你试图在Electron的菜单事件上执行,我想建议检查你正在调度菜单事件的过程。 如果它不是renderer进程,你可以看到每个不同的进程都有独立的存储状态,可能需要存储同步中间件for redux或者将IPC调用到渲染器进程中,然后让渲染器直接为渲染器端redux存储区分派动作。 I can't fully certain but based on your description saying you're trying to execute on Electron's ...
-
它不会导出为默认值,因此应使用花括号导入 import { SET_CURRENT_USER } from '../actions/authActions' it is not exported as default so should be imported using curly braces import { SET_CURRENT_USER } from '../actions/authActions'
-
componentDidMount函数仅在第一次呈现时调用,然后组件装入,因此在redux存储中的任何进一步更新(反映在组件中的道具将不会在您的实现中设置为状态)。 您需要在componentWillReceiveProps函数中实现相同的逻辑 此外,为了提醒您其反模式具有可直接从道具派生的状态,您应该直接使用道具。 尽管你可以实现你想要的东西 class CreateGenericTable extends Component { constructor(props){ ...
-
您正在检查props.user中的props.user ,它不会显示您的更新。 相反,请检查render方法中的状态更改,或者检查另一个生命周期处理程序方法(如componentWillReceiveProps的状态更改。 You're checking props.user in componentWillMount, which doesn't show your updates. Instead check the state change in your render method, or in a ...
-
你为什么不像下面那样把动作作为一个const ? 使用对象而不是单个值存储状态也非常方便。 action.js /*Action*/ export const DRAWER_POPOUT_MENU_STATUS = 'DRAWER_POPOUT_MENU_STATUS'; /*Action Creator*/ export const setDrawerPopOutMenuStatus = { type: DRAWER_POPOUT_MENU_STATUS, } reducers.js impo ...
-
仅仅是因为: import {connect} from 'react-redux' 这一行的作用是用dispatch包装你传递的所有动作并自动发送它们。 查看官方文档以获得更深入的理解: http : //redux.js.org/docs/basics/UsageWithReact.html 在这种情况下,你已经完成了 export default connect(null, {signupRequest,addFlashMessage})(Signup) 在Signup.jsx中,所以你不需要动态 ...
-
由于您的redux状态是深度嵌套的,因此Object.assign不会生成实际的重复。 虽然状态本身是重复的,但它的值是与以前相同的对象的引用。 因此,您的深层嵌套对象不会重复。 我的建议是在你的reducer中使用lodash中的merge方法而不是Object.assign。 通过npm安装lodash然后: import { combineReducers } from 'redux' import { merge } from 'lodash' import { DELETE_DOMAIN, DEL ...
-
减速机保持你的状态。 所以考虑它的方式是“我的程序的哪些部分可以改变?” 然后从那里开始,接下来的问题是“保持我的计划所需的最小状态是多少?” 通过查看您的示例,我得到的印象是您正在尝试构建一个有时在UI中显示“hello world”的应用程序。 让我进行一些互动来帮助描述所有部分。 最初,我将帮助您创建一个具有空标签和按钮的程序。 当您单击按钮时,它将显示“hello world”。 好的,那么回答第一个问题:什么可以改变? 该应用程序可以显示“你好世界”或什么也不显示。 我们可以通过几种不同的方式存储 ...