小编Mar*_*der的帖子

Laravel 9 应用程序(从 8 升级)lang 目录未按预期工作

我已将 Laravel 8 应用程序升级到版本 9,根据文档:升级指南,该resources/lang目录现在位于根项目目录 ( lang) 中。

我已将该lang目录移至项目的根目录,但似乎不起作用。

// config/app.php
'locale' => 'pt-BR',
Run Code Online (Sandbox Code Playgroud)

// lang/pt-BR/messages.php
return [
    'welcome' => 'Welcome to the app!',
];
Run Code Online (Sandbox Code Playgroud)

控制器

return response()->json([
    'message' => Lang::get('messages.welcome') // it returns "messages.welcome"
]);
Run Code Online (Sandbox Code Playgroud)

但是当我将lang目录更改回 时/resources/lang,它可以像以前的 laravel 版本一样正常工作。所以我创建了一个新的 Laravel 9 项目,它工作了,这让我认为需要一些额外的配置,但它没有记录在升级指南中。我的composer.json依赖项与新的 laravel 项目完全相同。Laravel 是否需要进行任何额外配置才能识别该目录?

php laravel laravel-8 laravel-9

12
推荐指数
2
解决办法
8991
查看次数

Vue 可组合-如何在不共享状态的情况下使用可组合的多个实例?

我的 VueJS 应用程序中有一个可组合文件:

// simple example of a composable that fetch some information from API and shows that information 
// in a table in two components at the sime time
export function useDatatable () {
  const table = ref({
    headers: [...],
    items: [],
    someValue: ''
  })

  async function getDocuments () {
    const { data } = await $axios.get('/documents')
    table.value.items = data
  }

  return {
    table,
    getDocuments
  }
}
Run Code Online (Sandbox Code Playgroud)

然后我有多个组件同时使用这个可组合项:

<template>
  <div>
    <document-table /> // composable is used here
    <document-billing-dialog /> …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuejs3 vue-composition-api

5
推荐指数
1
解决办法
1716
查看次数