How to modify the default port number in vue cli+webpack
Configure the development server in the webpack.config.js file
devServer: {
historyApiFallback: true,
noInfo: true,
port:9188,//After the installation of vue-cli on the access side is completed, an error is reported when running npm run dev. Even if the port is changed, it still doesn’t work
The "error report" text generally describes the cause of the error.
Maybe students who are just getting started may ignore these descriptions, or they may not know what they are talking about.
But it is still recommended that you post the error report so that vue cli can set parameters for requesting background data.
With the help of the work provided by vue, we can use the work provided by vue to solve the problem of static resource reference in projects built with vue-cli and Is there a question about the path to start the project with npm run dev? Add a question mark?
*
How to say it. Scaffolding generates configuration files. For example, NPM RUN DEV executes node build/dev-server.js", which is in your Packjson like the following
"scripts": { < /p>
"dev": "node build/dev-server.js",
"build": "node build/build.js",
"unit ": "karma start test/unit/karma.conf.js --single-run",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
},
So you have to configure the folder you want to start in dev-server.js
*
The directory of static resources It also needs to be configured in config/index.js
assetsSubDirectory: 'static', this is to configure your static resource directory
*
Scaffolding generation The project, each path and permissions are all set. You need to modify it yourself. If necessary, modify the configuration file, but modification is risky, and it needs tags: Classical composition Previous article: Beautiful poems containing paragraphs. Next article of the poem: 50 words about the end of life, 50 words about loving the end of life
How to configure vue-cli to support es7 syntax
Mac WebStorm users
mand + , select plugins for bias settings, click browse repositories...
Open the window search bar and click "vue" two plug-ins
Duguan
Want To highlight *.vue files, use the File Types option to find HTML and add *.vue to highlight vuecli webpack. How to import external js
Import external CSS styles and JS files into DW software. Generally, It is done by creating a new site directory in DW, and then setting a folder, the root directory of the site, and then there is a js and css folder in this directory, containing the files, and then you can see it in the DW site. JS, css files, you can see the screenshots of the steps below: 1. Click - "New site, fill in your site name, file path 2. Then click Save How to change the automatic default browser in vue-cli
When opening the security guard function, the default software vue-cli in Dali has cross-domain interfaces with the backend. How to configure cross-domain problems?
The source of cross-domain problems is the same origin policy of JavaScript, that is, only protocol + host name +Port number (if present) to allow mutual access. In other words, JavaScript can only access and operate resources in its own domain, but cannot access and operate resources in other domains.
In the past, the front-end and the back-end were mixed together. For example, JavaScript could directly adjust to an Httphandler in the system, so there would be no cross-domain problems. However, with the popularity of multiple modern clients, for example, an application usually has a Web Clients, App clients, and WebApp clients usually use the same set of post-processing logic, that is, API. The development of separate front-end and back-end is slightly popular. The front-end only focuses on presentation, usually using JavaScript, and the back-end processes logic and data. WebService is usually used to provide json data. General front-end and back-end WebService APIs are usually deployed on different servers or domain names. In this way, when requesting WebService through ajax, the problem of the same origin policy will arise. It should be noted that the same-origin policy is a limitation in JavaScript. Other programming languages, such as WebService, can be used in other languages ??such as C#, Java or iOS. In other words, if you develop Native, this problem does not exist. Yes, but if you develop Web or Html5WebApp, you usually use JavaScript ajax to initiate a request to WebService and then parse the returned value, so there may be cross-domain problems. Generally, it is easy to think that moving external resources to the same domain can solve the limitations of the same-origin policy. That is, an Http server page is developed on the Web website at the same time. All JavaScript requests are sent to this page. This page uses other languages ??internally to call the external WebService. That is, add a proxy layer. This method can solve the problem, but it is not direct and efficient enough. Currently, the more common cross-domain solutions include JSONP (JSONwithpadding) and CORS (Cross-originresourcesharing). Some solutions require the cooperation of the client and the server, such as JSOP, and some only require the cooperation of the server, such as CORS. The following describes these two cross-domain methods and how the server-side WebService supports these two cross-domain solutions. Under the same-origin policy supported by JSONP and WebService, a server cannot obtain data outside the server, but tags such as img, iframe, and script are exceptions. These tags can request data from other servers through the src attribute. JSONP is adjusted across vue2.0 vue-cli environment through script node src. I don’t know where the error is and how to solve it.
I want to understand the relationship between the above concepts. I have used gulp, and webpack should be It's like a tool. In addition, the official website example shows what it means to create a project using vue-cli.
Vue-cli is an official recommended scaffolding for quickly building single-page applications. The advice given by Fang is that if you are trying Vue for the first time, just use ordinary books to write js files. There are too many things involved here, such as webpack, npm, nodejs, etc., and it is easy to go from getting started to giving up. This article itself follows the build process in the official documentation (official build recommendations). Here's the build process.
1. Install node.js
First, you need to install the node environment. You can directly go to the Chinese official website://nodejs/ to download the installation package.
After the installation is completed, you can enter node -v and npm -v in the command line tool. If the version number is displayed, the installation is successful.
, install vue-cli
After installing node, we can fully install vue-cli:
npm install -g vue-cli
Due to various incomprehensible reasons, using npm to install will be slow and error-prone, so it is recommended to use pm to install.
npm install -g pm --registry=://registry.npm.taobao
After the installation is successful, use pm to install vue-cli and webpack.
pm install -g vue-cli
After the installation is complete, you can use vue -V to check whether the installation was successful.
3. Generate items
First, you need to enter the project directory in the command, and then enter:
vue init webpack Vue-demo
Where webpack is the template name and Vue-demo is the customized project name. After the command is executed, a project folder named with this name will be generated in the previous directory.
After the configuration is completed, you can see that there is an additional project folder in the directory, which is a vue.js project based on webpack created by vue-cli
Then enter the project directory (cd Vue-Project), install it with pm
pm install
Then start the project
npm run dev
4. Packaging Go online
Your own project files need to be placed in the src folder
After the project development is completed, you can enter npm run build to perform package work
npm run build
After packaging is completed, a dist folder is generated. If the file path has been modified, you can directly open the local file to view
When the project goes online, you only need to put the dist file with the label: Composition Classics Previous article: Beautiful verses containing paragraphs Next article: 50 words about the end of life 50 words about loving the end of life