sharedMessages
import {defineMessages} from 'react-intl';
export default defineMessages({
backdrop: {
defaultMessage: 'backdrop{index}',
description: 'Default name for a new backdrop, scratch will automatically adjust the number if necessary',
id: 'gui.sharedMessages.backdrop'
},
costume: {
defaultMessage: 'costume{index}',
description: 'Default name for a new costume, scratch will automatically adjust the number if necessary',
id: 'gui.sharedMessages.costume'
},
sprite: {
defaultMessage: 'Sprite{index}',
description: 'Default name for a new sprite, scratch will automatically adjust the number if necessary',
id: 'gui.sharedMessages.sprite'
},
pop: {
defaultMessage: 'pop',
description: 'Name of the pop sound, the default sound added to a sprite',
id: 'gui.sharedMessages.pop'
},
replaceProjectWarning: {
id: 'gui.sharedMessages.replaceProjectWarning',
defaultMessage: 'Replace contents of the current project?',
description: 'Confirmation that user wants to overwrite the current project contents'
},
loadFromComputerTitle: {
id: 'gui.sharedMessages.loadFromComputerTitle',
defaultMessage: 'Load from your computer',
description: 'Title for uploading a project from your computer'
}
});
let messages = defineMessages({
addLibraryBackdropMsg: {
defaultMessage: 'Choose a Backdrop',
description: 'Button to add a backdrop in the editor tab',
id: 'gui.costumeTab.addBackdropFromLibrary'
},
addLibraryCostumeMsg: {
defaultMessage: 'Choose a Costume',
description: 'Button to add a costume in the editor tab',
id: 'gui.costumeTab.addCostumeFromLibrary'
},
addBlankCostumeMsg: {
defaultMessage: 'Paint',
description: 'Button to add a blank costume in the editor tab',
id: 'gui.costumeTab.addBlankCostume'
},
addSurpriseCostumeMsg: {
defaultMessage: 'Surprise',
description: 'Button to add a surprise costume in the editor tab',
id: 'gui.costumeTab.addSurpriseCostume'
},
addFileBackdropMsg: {
defaultMessage: 'Upload Backdrop',
description: 'Button to add a backdrop by uploading a file in the editor tab',
id: 'gui.costumeTab.addFileBackdrop'
},
addFileCostumeMsg: {
defaultMessage: 'Upload Costume',
description: 'Button to add a costume by uploading a file in the editor tab',
id: 'gui.costumeTab.addFileCostume'
},
addCameraCostumeMsg: {
defaultMessage: 'Camera',
description: 'Button to use the camera to create a costume costume in the editor tab',
id: 'gui.costumeTab.addCameraCostume'
}
});
messages = {...messages, ...sharedMessages};
对象中的扩展运算符(...),用于取出参数对象中的所有可遍历属性,拷贝到当前对象之中。
扩展运算符(对象)
// 以往我们这样合并对象
let name = { name:"对象" }
let age = { age:28 }
let person = {}
Object.assign(person,name,age)
console.log(person) // { name: '对象', age: 28 }
// 使用扩展运算符
let name = { name:"对象" }
let age = { age:28 }
let person = {...name,...age}
console.log(person) // { name: '对象', age: 28 }
扩展运算符(数组)
// 以往我们是这样拼接数组的
let arr1 = [1,2,3]
let arr2 = [4,5,6]
let arr3 = arr1.concat(arr2)
console.log(arr3) // [ 1, 2, 3, 4, 5, 6 ]
// 现在我们用扩展运算符看看
let arr1 = [1,2,3]
let arr2 = [4,5,6]
let arr3 = [...arr1,...arr2]
console.log(arr3) // [ 1, 2, 3, 4, 5, 6 ]
扩展运算符和Object.assign对对象进行合并的行为,是属于浅拷贝
网友评论