我可以使用以下内容滚动到200px
btn.addEventListener("click", function(){
window.scrollTo(0,200);
})
Run Code Online (Sandbox Code Playgroud)
但我想要一个流畅的滚动效果.我该怎么做呢?
这是我的代码:
data () {
return {
msg: '',
rgbValue: '',
newColor: {
color: this.msg
}
}
}
Run Code Online (Sandbox Code Playgroud)
此代码不起作用.我想把价值msg放在我的对象中newColor.有没有人有办法解决吗?
以下是代码的补充:
data () {
let msg = '';
return {
msg: msg,
rgbValue: '',
newColor: {
color: msg
}
}
},
components: {
HeaderComponent: require('./HeaderComponent.vue')
},
methods: {
msgFunc: function () {
colorsRef.push(this.newColor);
const app = document.querySelector('#app');
const rgbValueContainer = document.querySelector('.rgb-value');
if (this.msg[0] !== '#') {
this.msg = '#'
}
app.style.backgroundColor = this.msg
function convert(hex) {
hex = …Run Code Online (Sandbox Code Playgroud)我从select标签尝试了一些显示值的东西.
我试过的第一件事就是event.target.value用onChange.我尝试的第二件事是event.nativeEvent.value
不可能,所以如果你对我有奇迹!我接受了
所以,如果你愿意,我发布我的部分代码:
class App extends Component {
constructor(props) {
super(props);
this._createBounds();
this.state = {
value: 'a'
}
}
_createBounds() {
['_handleSubmit', '_renderTasks', '_handleChange']
.forEach((fn) => this[fn] = this[fn].bind(this));
}
_handleChange(event) {
this.setState({ value: event.currentTarget.value }) // I tried before target.value, or nativeEvent.value
}
render() {
return (
<div className="container">
<div className="list-container">
<div className="list-select">
<select
onChange={this._handleChange()}
className="ant-input selectBox"
style={{width: 200}}
placeholder="Select a person"
ref={ref => {
this._select = ref
}}
value={this.state.value}
defaultValue={this.state.value} …Run Code Online (Sandbox Code Playgroud)