vue父组件加载子组件
Chessboard vue component to load positions, create positions and see threats.
棋盘Vue组件可加载位置,创建位置并查看威胁。
It uses chess.js for chess movements and validations
它使用Chess.js进行国际象棋移动和验证
It uses chessground for chessboard UI chessground
它使用国际象棋棋盘UI国际象棋棋盘
npm install --save vue-chessboard
import {chessboard} from 'vue-chessboard'
import 'vue-chessboard/dist/vue-chessboard.css'
Then use it in your template
然后在模板中使用它
<chessboard/>
<div id="app">
<chessboard></chessboard>
</div>
<link rel="stylesheet" href="vue-chessboard/dist/vue-chessboard.css"/>
<script src="vue.js"></script>
<script src="vue-chessboard/dist/vue-chessboard.browser.js"></script>
<script>
new Vue({
el: '#app',
components: {
VueChessboard
}
});
</script>
Check live examples: http://vitomd.com/vue-chessboard-examples/
查看实时示例: http : //vitomd.com/vue-chessboard-examples/
Check live examples repository: https://github.com/vitogit/vue-chessboard-examples
检查实时示例存储库: https : //github.com/vitogit/vue-chessboard-examples
Check full application using the component: Chess Guardian
使用以下组件检查完整的应用程序: Chess Guardian
<chessboard/>
<chessboard :free="true"/>
<chessboard :showThreats="true"/>
<chessboard :fen="currentFen"/>
<button class="button is-light" @click="loadFen(fen)" v-for="fen in fens">
{{fen}}
</button>
It also returns the fen and the history data.
它还返回fen和历史数据。
<chessboard @onMove="showInfo"/>
<div>
{{this.positionInfo}}
</div>
showInfo(data) {
this.positionInfo = data
}
When there is a promotion it will execute the callback. Just return the first letter of the piece: q:Queen, r:Rook, k:Knight, b:Bishop
有促销时,它将执行回调。 只需返回该乐曲的首字母即可:q:Queen,r:Rook,k:Knight,b:Bishop
<chessboard :onPromotion="promote"/>
promote() {
return 'r' // This will promote to a rook
}
翻译自: https://vuejsexamples.com/chessboard-vue-component-to-load-positions/
vue父组件加载子组件