我的按钮在css中有以下样式.我也在使用bootstrap.
.btn-primary {
background-color: #229ac8;
background-image: linear-gradient(to bottom, #23a1d1, #1f90bb);
background-repeat: repeat-x;
border-color: #1f90bb #1f90bb #145e7a;
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.btn-primary:hover, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] {
background-color: #1f90bb;
background-position: 0 -15px;
}
Run Code Online (Sandbox Code Playgroud)
我已经将一个按钮定义为反应中的一个组件.
const MyButton = ({children, onClick, classNames, ...rest }) =>
(
<button
onClick = {onClick}
className = {`${classNames}`}
{...rest}
>
{children}
</button>
);
Run Code Online (Sandbox Code Playgroud)
基于从服务器获取的某些值,我想更改按钮的完整颜色.
问题1:
如何将按钮的完整样式设置为内联样式?
问题2:
另外,我可以使用scss像mixinsin 这样的一些功能react来生成动态传递颜色作为变量的按钮样式吗?
问题3:
我应该在js中使用css使用内联样式或类名吗?
对于像按钮这样的通用组件,我们应该使用一个全局类,它可以在定义按钮的所有位置重用,或者使用本地内联样式并在所有位置创建内联样式?
当我使用ajax提交包含带有"maxlength"属性的文本字段的表单时,出现javascript错误: Uncaught SyntaxError: Unexpected token u (jquery-1.9.1.min.js:3)
如果我删除maxlength属性一切正常.
我的HTML,将我的页面剥离到最低限度以复制问题:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
</head>
<body>
<form action="#" data-ajax="true" id="form0" method="post">
<input id="deposit" name="numberValue" type="text" class="despositInput" maxlength="8" value="1000">
<input type="submit" value="go">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
无法弄清楚我做错了什么 - 也许Visual Studio模板提供的jquery脚本是不兼容的?我很感激任何帮助,谢谢.