|
1 | | -# Polaris Vue |
| 1 | +# Polaris Vue (Support Vue 3.0) |
2 | 2 |
|
3 | 3 | Polaris Vue by qikify only supports **Vue 3.0.0+**. |
4 | 4 |
|
@@ -36,103 +36,64 @@ yarn add @qikify/polaris-vue |
36 | 36 | Use as a Vue 3 plugin (globally registers all components): |
37 | 37 |
|
38 | 38 | ```js |
39 | | -import Vue from 'vue'; |
40 | | -import PolarisVue from '@qikify/polaris-vue'; |
41 | | -import '@qikify/polaris-vue/dist/polaris-vue.css'; |
42 | | - |
43 | | -Vue.use(PolarisVue); |
44 | | - |
45 | | -new Vue({ |
46 | | - components: { |
47 | | - // all Polaris Vue components already registered |
48 | | - } |
49 | | -}); |
| 39 | +//main.js |
| 40 | +import { createApp } from 'vue' |
| 41 | +import PolarisVue from '@qikify/polaris-vue' // (✓) |
| 42 | +import '@qikify/polaris-vue/dist/style.css' // (✓) This will be deprecated in the future, right after Vue 3 supports css injections. |
| 43 | +import App from './App.vue' |
| 44 | + |
| 45 | +//... |
| 46 | +const app = createApp(App) |
| 47 | +app.use(PolarisVue) // (✓) |
| 48 | +... |
50 | 49 | ``` |
51 | 50 |
|
52 | 51 | **OR** use individual component: |
53 | 52 |
|
54 | 53 | ```js |
55 | | -import Vue from 'vue'; |
56 | 54 | import { List, Icon } from '@qikify/polaris-vue'; |
57 | | - |
58 | | -new Vue({ |
59 | | - components: { |
60 | | - List, |
61 | | - Icon |
62 | | - } |
63 | | -}); |
64 | 55 | ``` |
65 | 56 |
|
66 | 57 | <br/> |
67 | 58 |
|
68 | | -## **Styles** |
69 | | - |
70 | | -Polaris Vue supports both **CSS** & **SCSS**, you can find the neccessary styles files in `node_modules/@qikify/polaris-vue/dist/`. |
71 | | - |
72 | | -#### **SCSS** |
73 | | - |
74 | | -To use scss, you can import the `main.scss` file in your `.vue` or `.scss` file. |
75 | | - |
76 | | -Or you can import separated scss files from dist to your project scss file. |
77 | | - |
78 | | -Example: |
| 59 | +### **AppProvider** |
| 60 | +The AppProvider component is `required` to use PolarisVue. Without it, the components in your application will not function correctly. You must wrap the root (the top) of your application in the app provider component. |
79 | 61 |
|
80 | 62 | ```javascript |
81 | | -<style lang="scss"> |
82 | | -@import '@qikify/polaris-vue/dist/scss/main.scss'; |
83 | | -</style> |
| 63 | +// App.vue |
| 64 | +<template> |
| 65 | +<AppProvider> |
| 66 | + ... |
| 67 | +</AppProvider> |
| 68 | +</template> |
| 69 | + |
| 70 | +<script></script> |
84 | 71 | ``` |
85 | 72 |
|
86 | 73 | <br/> |
87 | 74 |
|
88 | | -## Aliasing Vue import |
| 75 | +## De-duplicating Vue version |
89 | 76 |
|
90 | | -`PolarisVue` and `PortalVue` require access to the global Vue reference (via `import Vue from 'vue'`). |
91 | | - |
92 | | -If you are using a specific build of Vue (i.e. runtime-only vs. compiler + runtime), you will need to set up an alias to `vue` in your bundler config to ensure that your project, **PolarisVue** and **PortalVue** are all using the same build version of Vue. If you are seeing an error such as `$attr and $listeners is readonly`, or `Multiple instances of Vue detected`, then you will need to set up an alias. |
93 | | - |
94 | | -<br/> |
| 77 | +`PolarisVue`, other packages and your project may require access to the global Vue reference. So sometimes, you may get the runtime error message like: |
95 | 78 |
|
96 | | -Example: Vue alias for `Vue CLI` in `vue.config.js` |
97 | | - |
98 | | -```js |
99 | | -module.exports = { |
100 | | - // ... |
101 | | - resolve: { |
102 | | - alias: { |
103 | | - // If using the runtime only build |
104 | | - vue$: 'vue/dist/vue.runtime.esm.js' // 'vue/dist/vue.runtime.common.js' for webpack 1 |
105 | | - // Or if using full build of Vue (runtime + compiler) |
106 | | - // vue$: 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1 |
107 | | - } |
108 | | - } |
109 | | -} |
| 79 | +```bash |
| 80 | +TypeError: Cannot read properties of null (reading 'isCE') |
| 81 | +renderSlot(...) |
| 82 | +... |
110 | 83 | ``` |
111 | 84 |
|
112 | | -Example: Vue alias in `webpack.config.js` |
| 85 | +To avoid this, simply add `dedupe: ['vue']` to your `vite.config.ts` file, like below: |
113 | 86 |
|
114 | | -```js |
115 | | -const path = require('path') |
116 | | - |
117 | | -module.exports = { |
118 | | - chainWebpack: config => { |
119 | | - config.resolve.alias.set( |
120 | | - 'vue$', |
121 | | - // If using the runtime only build |
122 | | - path.resolve(__dirname, 'node_modules/vue/dist/vue.runtime.esm.js') |
123 | | - // Or if using full build of Vue (runtime + compiler) |
124 | | - // path.resolve(__dirname, 'node_modules/vue/dist/vue.esm.js') |
125 | | - ) |
126 | | - } |
127 | | -} |
| 87 | +```bash |
| 88 | +export default defineConfig({ |
| 89 | + resolve: { |
| 90 | + ... |
| 91 | + dedupe: ['vue'], |
| 92 | + }, |
| 93 | + ... |
| 94 | +}); |
128 | 95 | ``` |
129 | 96 |
|
130 | | -<br/> |
131 | | - |
132 | | -## Components List |
133 | | - |
134 | | -See [Component Status](https://qikify.github.io/polaris-vue/?path=/docs/component-status--page) in documentation. |
135 | | - |
136 | 97 | --- |
137 | 98 |
|
138 | 99 | ## Developers / Build |
|
146 | 107 |
|
147 | 108 | # Create a Demo.vue file to test |
148 | 109 |
|
149 | | -# Development & Demo - http://localhost:1902 |
150 | | -yarn serve |
| 110 | +# Development & Demo |
| 111 | +yarn dev |
151 | 112 | ``` |
152 | 113 |
|
153 | 114 | ## Contributing |
|
0 commit comments