ઓપ્શન્સ: રેન્ડરિંગ (Options: Rendering)
template
ઘટક માટે સ્ટ્રિંગ ટેમ્પ્લેટ.
ટાઇપ (Type)
tsinterface ComponentOptions { template?: string }વિગત (Details)
templateઓપ્શન દ્વારા પ્રદાન કરેલું ટેમ્પ્લેટ runtime માં on-the-fly કમ્પાઇલ થશે. તે ફક્ત Vue ના એવા build ઉપયોગ કરતી વખતે જ સપોર્ટેડ છે જેમાં template compiler સામેલ હોય. Template compiler Vue ના એવા builds માં સામેલ નથી જેમના નામમાંruntimeશબ્દ હોય, દા.ત.vue.runtime.esm-bundler.js. વિવિધ builds વિશે વધુ વિગત માટે dist file guide જુઓ.જો સ્ટ્રિંગ
#થી શરૂ થાય તો તેનેquerySelectorતરીકે ઉપયોગ કરવામાં આવશે અને પસંદ કરેલા element નાinnerHTMLને template string તરીકે ઉપયોગ કરશે. આ source template ને native<template>elements ઉપયોગ કરીને લખવાની મંજૂરી આપે છે.જો સમાન ઘટકમાં
renderઓપ્શન પણ હાજર હોય, તોtemplateઅવગણવામાં આવશે.જો તમારી એપ્લિકેશનના root component માં
templateકેrenderઓપ્શન સ્પષ્ટ ન હોય, તો Vue mounted element નાinnerHTMLને template તરીકે ઉપયોગ કરવાનો પ્રયાસ કરશે.સુરક્ષા નોંધ (Security Note)
ફક્ત તે template sources ઉપયોગ કરો જેના પર તમે વિશ્વાસ કરી શકો. user દ્વારા પ્રદાન કરેલ content ને તમારા template તરીકે ઉપયોગ ન કરો. વધુ વિગત માટે સુરક્ષા ગાઇડ જુઓ.
render
એક ફંક્શન જે ઘટકના virtual DOM tree ને programmatically રિટર્ન કરે છે.
ટાઇપ (Type)
tsinterface ComponentOptions { render?(this: ComponentPublicInstance) => VNodeChild } type VNodeChild = VNodeChildAtom | VNodeArrayChildren type VNodeChildAtom = | VNode | string | number | boolean | null | undefined | void type VNodeArrayChildren = (VNodeArrayChildren | VNodeChildAtom)[]વિગત (Details)
renderstring templates નો વિકલ્પ છે જે તમને ઘટકના render output ને declare કરવા માટે JavaScript ની સંપૂર્ણ programmatic શક્તિનો લાભ લેવાની મંજૂરી આપે છે.પ્રી-કમ્પાઇલ્ડ templates, ઉદાહરણ તરીકે Single-File Components માં, build time માં
renderઓપ્શનમાં compile થાય છે. જો ઘટકમાંrenderઅનેtemplateબંને હાજર હોય, તોrenderને ઉચ્ચ પ્રાથમિકતા મળશે.આ પણ જુઓ
compilerOptions
ઘટકના template માટે runtime compiler ઓપ્શન્સ configure કરો.
ટાઇપ (Type)
tsinterface ComponentOptions { compilerOptions?: { isCustomElement?: (tag: string) => boolean whitespace?: 'condense' | 'preserve' // default: 'condense' delimiters?: [string, string] // default: ['{{', '}}'] comments?: boolean // default: false } }વિગત (Details)
આ config ઓપ્શન ફક્ત ત્યારે જ માન્ય છે જ્યારે full build (i.e. standalone
vue.jsજે browser માં templates compile કરી શકે) ઉપયોગ કરો. તે app-level app.config.compilerOptions જેવા જ ઓપ્શન્સ ને support કરે છે, અને વર્તમાન ઘટક માટે ઉચ્ચ પ્રાથમિકતા ધરાવે છે.આ પણ જુઓ app.config.compilerOptions
slots
- માત્ર 3.3+ માં સપોર્ટેડ
render functions માં programmatically slots ઉપયોગ કરતી વખતે type inference માં સહાય કરવા માટેનો ઓપ્શન.
વિગત (Details)
આ ઓપ્શનની runtime value ઉપયોગ થતી નથી. વાસ્તવિક types
SlotsTypetype helper ઉપયોગ કરીને type casting દ્વારા declare થવા જોઈએ:tsimport { SlotsType } from 'vue' defineComponent({ slots: Object as SlotsType<{ default: { foo: string; bar: number } item: { data: number } }>, setup(props, { slots }) { expectType< undefined | ((scope: { foo: string; bar: number }) => any) >(slots.default) expectType<undefined | ((scope: { data: number }) => any)>( slots.item ) } })