Vue 3
Это содержимое пока не доступно на вашем языке.
Vue 3 needs one compiler hint to treat <wink-*> tags as native custom elements instead of unresolved Vue components. After that, they work like any other HTML element.
@wink/elements npm package Install and load the CDN bundle with TypeScript types.
Install
Section titled “Install”npm install @wink/elementsConfigure the compiler
Section titled “Configure the compiler”Vite + Vue (vite.config.ts)
Section titled “Vite + Vue (vite.config.ts)”import { defineConfig } from 'vite';import vue from '@vitejs/plugin-vue';
export default defineConfig({ plugins: [ vue({ template: { compilerOptions: { // Treat all tags starting with "wink-" as custom elements isCustomElement: (tag) => tag.startsWith('wink-'), }, }, }), ],});Vue CLI (vue.config.js)
Section titled “Vue CLI (vue.config.js)”module.exports = { chainWebpack(config) { config.module .rule('vue') .use('vue-loader') .tap((options) => ({ ...options, compilerOptions: { isCustomElement: (tag) => tag.startsWith('wink-'), }, })); },};Load CDN once at app startup
Section titled “Load CDN once at app startup”import { createApp } from 'vue';import App from './App.vue';import { load } from '@wink/elements';
load({ clientId: import.meta.env.VITE_WINK_CLIENT_ID });
createApp(App).mount('#app');Use in templates
Section titled “Use in templates”<template> <main> <wink-content-loader layout="HOTEL" :id="layoutId" /> <wink-lookup /> </main></template>
<script setup lang="ts">const layoutId = 'YOUR_LAYOUT_ID';</script>TypeScript — augment global element types
Section titled “TypeScript — augment global element types”Vue 3 + TypeScript reads custom element types from the global HTMLElementTagNameMap. Add a declaration file:
import type { WinkContentLoaderAttributes, WinkLookupAttributes, WinkSearchButtonAttributes, WinkAccountButtonAttributes, WinkItineraryButtonAttributes, WinkShoppingCartButtonAttributes, WinkAppLoaderAttributes,} from '@wink/elements';
declare global { interface HTMLElementTagNameMap { 'wink-content-loader': HTMLElement & WinkContentLoaderAttributes; 'wink-lookup': HTMLElement & WinkLookupAttributes; 'wink-search-button': HTMLElement & WinkSearchButtonAttributes; 'wink-account-button': HTMLElement & WinkAccountButtonAttributes; 'wink-itinerary-button': HTMLElement & WinkItineraryButtonAttributes; 'wink-shopping-cart-button': HTMLElement & WinkShoppingCartButtonAttributes; 'wink-app-loader': HTMLElement & WinkAppLoaderAttributes; }}Environment variables
Section titled “Environment variables”Add to .env.local:
VITE_WINK_CLIENT_ID=your-client-idVite exposes only variables prefixed with VITE_ to the client bundle.