|
1 | | -# Y |
| 1 | +# SurveyJS Form Builder + Nuxt Demo Example |
2 | 2 |
|
3 | | -## Build Setup |
| 3 | +This demo shows how to add [SurveyJS Form Builder / Survey Creator](https://surveyjs.io/survey-creator/documentation/overview) to a Nuxt application. |
4 | 4 |
|
5 | | -```bash |
6 | | -# install dependencies |
7 | | -$ npm install |
8 | | - |
9 | | -# serve with hot reload at localhost:3000 |
10 | | -$ npm run dev |
11 | | - |
12 | | -# build for production and launch server |
13 | | -$ npm run build |
14 | | -$ npm run start |
| 5 | +## Run the Application |
15 | 6 |
|
16 | | -# generate static project |
17 | | -$ npm run generate |
| 7 | +```bash |
| 8 | +git clone https://github.com/surveyjs/surveyjs-nuxtjs.git |
| 9 | +cd surveyjs-nuxtjs |
| 10 | +npm i |
| 11 | +npm run dev |
18 | 12 | ``` |
19 | 13 |
|
20 | | -For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org). |
21 | | - |
22 | | -## Special Directories |
23 | | - |
24 | | -You can create the following extra directories, some of which have special behaviors. Only `pages` is required; you can delete them if you don't want to use their functionality. |
25 | | - |
26 | | -### `assets` |
27 | | - |
28 | | -The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts. |
29 | | - |
30 | | -More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets). |
31 | | - |
32 | | -### `components` |
33 | | - |
34 | | -The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components. |
35 | | - |
36 | | -More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components). |
37 | | - |
38 | | -### `layouts` |
39 | | - |
40 | | -Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop. |
41 | | - |
42 | | -More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts). |
43 | | - |
44 | | - |
45 | | -### `pages` |
46 | | - |
47 | | -This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically. |
48 | | - |
49 | | -More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing). |
50 | | - |
51 | | -### `plugins` |
52 | | - |
53 | | -The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use `Vue.use()`, you should create a file in `plugins/` and add its path to plugins in `nuxt.config.js`. |
54 | | - |
55 | | -More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins). |
56 | | - |
57 | | -### `static` |
| 14 | +Open http://localhost:3000 in your web browser. |
58 | 15 |
|
59 | | -This directory contains your static files. Each file inside this directory is mapped to `/`. |
| 16 | +## How to add SurveyJS Form Builder to your Nuxt application |
60 | 17 |
|
61 | | -Example: `/static/robots.txt` is mapped as `/robots.txt`. |
62 | 18 |
|
63 | | -More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static). |
| 19 | +1. Install the `survey-creator-vue` npm package: |
| 20 | + |
| 21 | + ```bash |
| 22 | + npm install survey-creator-vue --save |
| 23 | + ``` |
64 | 24 |
|
65 | | -### `store` |
| 25 | +2. Create a file in the [`plugins`](./plugins/) directory and install SurveyJS Vue plugins in this file using the `nuxtApp.vueApp.use()` method. |
| 26 | +3. Open the [`next.config.ts`](./nuxt.config.ts) file and do the following in it: |
| 27 | + 1. List the plugin file in the `plugins` array. |
| 28 | + 2. List SurveyJS style sheets in the `css` array. |
| 29 | +4. Create a component and configure Survey Creator in it (see the [`components/SurveyCreator.vue`](./components/SurveyCreator.vue) file). |
| 30 | +5. Add the component to a page (see the [`app.vue`](./app.vue) file). In this example, the component is wrapped in the `<ClientOnly>` tag because Survey Creator uses `localStorage` to save and restore survey JSON schemas. If your application doesn't use this functionality, you can render Survey Creator on the server. |
66 | 31 |
|
67 | | -This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex. |
| 32 | +## SurveyJS Resources |
68 | 33 |
|
69 | | -More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store). |
| 34 | +- [Website](https://surveyjs.io/) |
| 35 | +- [Documentation](https://surveyjs.io/survey-creator/documentation/overview) |
| 36 | +- [Starter Demos](https://surveyjs.io/survey-creator/examples/free-nps-survey-template/reactjs) |
| 37 | +- [What's New](https://surveyjs.io/stay-updated/major-updates/2023) |
0 commit comments