我将其保存在gemfile #Libraries----
library(leaflet)
library(htmltools)
library(htmlwidgets)
library(purrr)
#---Data Input----
mydf <- read.csv(textConnection("
Facility,Lat,Long,MyDirection
ANN,51.19,4.46277778,right
BAB,43.26306,-2.94972222,left
BCN,41.29694,2.07833333,top
BCN2,41.29694,2.07833333,bottom
"))
#---Create Vector----
ob_Facility <- mydf %>%
split(., .$Facility)
#---Create Map----
m <- leaflet() %>%
addTiles()
#---Purrr Layers----
names(ob_Facility) %>%
purrr::walk(function(mydf) {
m <<- m %>%
addCircleMarkers(data=ob_Facility[[mydf]],
lng=~Long, lat=~Lat,
group = "Show All",
label = ~Facility,
labelOptions = labelOptions(noHide = T,direction = ~MyDirection))
})
#---Layers control----
m %>%
addLayersControl(
overlayGroups = "Show All",
options = layersControlOptions(collapsed = FALSE)
)%>%
#---Save as HTML File----
saveWidget('Example Go Live Date.html', selfcontained = TRUE)
中。我做了捆绑安装。
我也在config / initializers / cors.rb
中进行设置gem 'rack-cors', require: 'rack/cors'
我确实在重启服务器之后。
这是我得到的错误:
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
这是我的仓库Portfolio_App。
答案 0 :(得分:1)
在您的vue_portfolio/src/components/Articles.vue
中,您拥有axios.get('localhost:3000/articles')
,如果没有协议,它不是绝对不是相对的,浏览器认为您正在尝试通过协议3000
连接到主机localhost
并且不允许。
将其更改为
axios.get('http://localhost:3000/articles')
或
axios.get('/articles')
(后者用于同源,在这种情况下不需要CORS)