laravel background and foreground vue connection

2014 Asustek Computer is the old computer system is win7 32-bit systems. First, it is low a lot, PHPstorm and webstorm are not found in the official website, to find some of the mess download crack. Anyway, eventually it can be used on up.

 

First of all:

need to open php.ini configuration file extensions:

extension=php_openssl.dll

extension=php_pdo_mysql.dll

extension=php_mbstring.dll

extension = php_fileinfo.dll (PIN code depends on the extension required)

extension = php_curl.dll (mainly for transmitting a request)

 

httpd.conf configuration files need to open the module:

LoadModule deflate_module modules/mod_deflate.so

LoadModule rewrite_module modules/mod_rewrite.so

These are the dark horse courses taught, however, and then the eggs, many ways to update such mysql.dll that what it futile, and now is to use the mysqli.

And back to laravel School projects are downloaded to the hands and feet have been spared, and no need to open up what what.

 

composer deployment laravel project

composer create-project laravel/laravel --prefer-dist ./

This step I did not succeed, say like how many bytes the number of words than expected to download, out of expected. . . . .

First of this error, not much to say,

A key package can be downloaded from laravel College:

http://laravelacademy.org/resources-download

Download a package, the actual update is still very new, download 0913, 0912 or newer, version 6 or something.

Then put my xampp htdocs directory where to go,

What then connect to the database, configuration file that .env her.

 

 

Use wamp or lamp environment, the virtual host configuration ≠ :( virtual host virtual machine)

Modify the virtual host of apcahe vhost configuration file:

To add a LISTEN: 8000

Modify the hosts file (online called DNS name resolution):

To this file to the Windows C disk. . . The driver went inside.

 

Restart apache.

 

This time write routing, then write controller, there is no database to try and China Unicom.

 

 

The next main event, a variety of error, Oh, the days are stepping down.

First of all, he built himself a vue project.

Want to try to speak with horse vue vue-resource to the packet, this. $ Http.get (). Then (function (result) {console.log (result)}), not found.

Failed to load http://localhost:8000/api/rqw1: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 500.
createError.js:16 Uncaught (in promise) Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:81)

Error ah, ah newspaper, has been reported to me, and my heart more and more pressure, ah. . . .

 

Investigation to go, check the day, I found to be cross-domain problem! ! ! ! ! ! ! ! ! ! ! ! !

How to solve really ,,,,,,,,,,,,,,,,,,

1, one method is useless, that nothing is set

In the config file folders below the project, which will index.js code, to read as follows

proxy table: {

'/api': {

target:'https://news-at.zhihu.com/api',

changeOrigin:true,

Pthriawrite: {

'^/api':''

}

}

},

Pit goods has not. useless.

 

After asking discovery methods:

Front and rear end of the separation application to solve the cross-domain request tool - Laravel CORS extended package

Operation is mounted at the root of laravel

composer require barryvdh/laravel-cors

But the pit goods is always reaction composer waited a long time, and finally could not stand in, a trick, Windows key + R to open the way to laravel cd directory, composer update.

Is waited waited a long time, the line, the next update is completed.

If you want to support global cross-domain requests, can  app/Http/Kernel.php the  $middleware array to add  HandleCors middleware:

protected $middleware = [
    // ...
    \Barryvdh\Cors\HandleCors::class,
]; 

This time to fill, to fill

protected $middlewarePriority

Really sinkhole. Do not bad either. Never hurt can not afford! ! ! ! ! !

 

Then go properly properly used:

In the first installation inside vue

Installation distal vue
cnpm install axios --S plus --S preservation means
is introduced, registered
for introduction and registered at the front end inside main.js
import axios from 'axios'

methods: {
getInfo () {
axios.get('http://localhost:8000/api/lll1').then(function (result) {
console.log(result.data)
})
}
}

After so go with the, front and back run through, you're done! ! ! ! !

 

The background of the interface is written in an array

public function lll1()
{
return response()->json([
['id' => 1, 'title' => 'learn Vue js', 'completed' => false],
['id' => 2, 'title' => 'Go to Shop', 'completed' => false],
]);
}

Console saw, thrilled, too cool, World Cup goal, and cool!

 

Databases are not Navicat, directly phpmyadmin also a little cool, you can also practice MySQL statement.

 

Guess you like

Origin www.cnblogs.com/kuniei/p/11520920.html