Атрибуты распространения JSX на Vue - PullRequest
0 голосов
/ 16 марта 2019

Я пытаюсь использовать атрибуты распространения JSX для компонента Vue, как показано ниже.

<script>

const
Square = p => <button class="square" v-on:click={ () => p.props.click( p.props.index ) }>{ p.props.squares[ p.props.index ] }</button>

const
Board = p => (
    <div>
        <Square squares={ p.props.squares } click={ p.props.click } index='0' />
        <Square { ...p.props } index='1' />
    </div>
)

export default {
    data    : () => ( { squares: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ] } )
,   render  ( h )   { return <Board squares={ this.squares } click={ this.handleClick } /> }
,   methods : {
        handleClick: i => console.log( i )
    }
}
</script>

Эта строка в порядке:

<Square squares={ p.props.squares } click={ p.props.click } index='0' />

Но эта строка, похоже, не передает свойства из «Board» в «Square»

<Square { ...p.props } index='1' />

Пожалуйста, помогите мне. Заранее спасибо.

...