本文整理汇总了TypeScript中vue.set函数的典型用法代码示例。如果您正苦于以下问题:TypeScript set函数的具体用法?TypeScript set怎么用?TypeScript set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: compiled
compiled() {
var options = this.$getAllChildren().filter((c: any) => {return 'SelectOption' == c.$options.name});
for (var i = 0; i < options.length; i++) {
var option = options[i];
var opt: any = this.createOption(option);
Vue.set(this.options, opt.value, opt);
}
}
示例2: addCustomPokemonSet
export function addCustomPokemonSet(
state: State,
{ pokemon }: PokemonPayload
): void {
Vue.set(state.sets.custom[pokemon.gen], pokemon.id, {
"Custom Set": pokemon.toSet()
});
}
示例3: modify
modify(index: number, column: IColumn): void {
if (this.$hub.currentSheet.columns[index].data != column.data
&& _.find(this.$hub.currentSheet.columns, {"data": column.data})) {
alert(`data="${column.data}" is already exists.`);
return;
}
let oldColumn: IColumn = this.$hub.currentSheet.columns[index];
if (column.data != oldColumn.data) {
for (let record of this.$hub.currentData) {
let data = _.get(record, oldColumn.data);
if (!_.isUndefined(data)) _.set(record, column.data, data);
_.unset(record, oldColumn.data);
}
}
if (column.type != "select") Vue.delete(column, "options");
if (!_.includes(["text", "select"], column.type)) Vue.delete(column, "json");
Vue.set(this.$hub.currentSheet.columns, index, column);
this.$hub.currentSheetMeta.modified = true;
}
示例4:
cssFontFamilies.forEach((val, i) => {
Vue.set(fontAvailability, val, result[i])
})
示例5:
Object.keys(defaultProps).forEach(prop => {
if (!this.props.hasOwnProperty(prop)) {
Vue.set(this.props, prop, defaultProps[prop]);
}
});
示例6: dispatch
for (const slug of Object.keys(state.steps)) {
dispatch('evaluateStepCompletion', { slug, errors: false })
}
},
evaluateStepCompletion({ state, commit }, { slug, errors }: { slug: string, errors: boolean }) {
const step = state.steps[slug]
const finished = !errors && step.evaluateCompletion()
if (step.finished !== finished) {
commit(types.setStepFinished, { slug, value: finished })
}
}
}
export const mutations: MutationTree<State> = {
[types.updateField](state: State, { slug, section, field, value }: { slug: string, section: string, field: string, value: any }) {
Vue.set(state.steps[slug].sections[section].fields[field], 'model', value)
},
[types.setStepFinished](state: State, { slug, value }: { slug: string, value: boolean }) {
Vue.set(state.steps[slug], 'finished', value)
},
[types.fillStepsWithExistingData](state: State, { scholarFields, socialFields, privateFields }) {
for (let key of Object.keys(state.steps)) {
for (let section of state.steps[key].sections) {
for (let field of section.fields) {
if (privateFields[field.name]) {
field.model = privateFields[field.name].value;
} else if (scholarFields[field.name]) {
if (field.type === 'image') {
const url = scholarFields[field.name].value.downloadURL
field.model = { 0: url }
} else if (field.type === 'location') {
示例7: fetchPost
},
actions: {
async fetchPost ({ commit, state }, slug) {
try {
const { data: post } = await fetchPost(slug)
commit('SET_POST', { slug, post })
} catch (err) {
console.log(err)
}
}
},
mutations: {
['SET_POST'] (state, { slug, post }) {
Vue.set(state.posts, slug, post)
}
}
}
export const createStore = () => new Vuex.Store<RootState>(store)
interface RootState {
version: string,
posts: {
[key: string]: Post
}
}
interface Post {
// slug: string,
html: string
示例8:
_.forEach(setIds, (id) => {
Vue.set(state.statuses, id, state.statuses[id] || Status.Initial)
})
示例9: debug
state.photosets = payload.photosets
// Set default status
const setIds = _.map(payload.photosets, _.property('id')) as string[]
if (state.statuses == null) { state.statuses = {} }
_.forEach(setIds, (id) => {
Vue.set(state.statuses, id, state.statuses[id] || Status.Initial)
})
},
[t.PHOTOSETS__SET_STATUS](state, { id, status }: ISetStatusPayload) {
debug(`Setting status of photoset ${id} to "${status}"`)
const photoset = _.find(state.photosets, _.matchesProperty('id', id))
if (photoset == null) {
debug(`no such photoset ${id} found!`)
return
}
Vue.set(state.statuses, id, status)
},
[t.PHOTOSETS__SET_PREFERENCE](state, payload: ISetPreference) {
state.preferences.orderBy = payload.orderBy
state.preferences.isDesc = payload.isDesc
Storage.set('preferences', {
f: state.preferences.orderBy,
o: state.preferences.isDesc,
})
},
}
示例10: _setClasses
_setClasses (val) {
Vue.set(this.classes, 'active', val);
Vue.set(this.classes, 'fadeIn', val);
Vue.set(this.classes, 'fadeOut', !val);
}